Quick question: MouseListener and multi threading

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Quick question: MouseListener and multi threading

Andreas Drewke
Hi,

Quick question.

I've a single thread where my java program runs in simple said.
I need to know now if calls to a class implementing MouseListener interface are from the main thread or from another thread.

This is important to know as I put events into a queue. This needs to be thread safe if mouseXXX(MouseEvent event) is called from another thread than the main thread.

Thank you very much in advance.

Best regards
Andreas Drewke
Reply | Threaded
Open this post in threaded view
|

Re: Quick question: MouseListener and multi threading

gouessej
Administrator
Hi

If you use AWT or Swing, then it's none of our concern, it's not a JOGL question but I'll try to answer anyway. AWT and Swing methods must be called on the Swing event dispatching thread, you can call SwingUtilities.invokeLater() and invokeAndWait() from your own thread. Swing/AWT listeners are called on the event dispatching thread too.

If you use NEWT, some methods are lifecycle heavy and mustn't be called on the EDT. Window.enqueueEvent() is similar to invokeLater() and invokeAndWait(). The NEWT listeners are called on the event dispatching thread which isn't the same as the one used by Swing and AWT and this isn't the same as OpenGL (see GLAutoDrawable.invoke(boolean, GLRunnable)).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Quick question: MouseListener and multi threading

Andreas Drewke
>The NEWT listeners are called on the event dispatching thread which isn't the same as the one used by Swing and AWT and this isn't the same as OpenGL (see GLAutoDrawable.invoke(boolean, GLRunnable))

Thanks. This is exactly what I wanted to know.

Best regards
Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Quick question: MouseListener and multi threading

gouessej
Administrator
You're welcome. I advise you to look at our Java API documentation, it contains this kind of information.
Julien Gouesse | Personal blog | Website