onMessage() and thread synchronization
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hamideh_Mostafavi
Posted On:   Thursday, February 14, 2002 11:27 AM

I use JMS PTP Asynchronous Message transmission. When there is an asynchronous listener on a JMS queue, a new thread is created to handle new messages passed to the queue. Each time a new message is received, onMessage(Message msg) is called. In my code, onMessage() code accesses the receiver application's existing objects (e.g. using JFrame.getFrames()).


Should I add synchronized lock to the methods accessed by onMessage() code to avoid race condition between two threads?


or Java takes care of it like other listeners?


Thanks.

Re: onMessage() and thread synchronization

Posted By:   Benoit_Quintin  
Posted On:   Thursday, February 14, 2002 12:38 PM

If you have (possibly) multiple message threads accessing your client's application, and that that data is used in the windowing, you should definitely synchronize (lock) the method to update your app. If, on the other hand, all threads run their own copy of the client app, then you probably won't have to bother.
About | Sitemap | Contact