In my main thread I create and start a new Thread(B). From within the run method of Thread B I invoke a public method of my Main class. This method is currently getting executed in Thread B instead I want that method to get executed in Thread Main. Is this possible?

John Zukowski

Since the method is called by the created thread, it is run by the created thread. In order for the method to be executed in the main thread, you must setup some signalling mechanism to tell the main thread to execute the method. JMS is probably overkill, but you can easily do a wait/notify between the two.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact