Uderc programming article aggregator sites

Problem with threads communication

Tags:
Answers: Have 2 answers
Advertisement
Hi All
I have a multithreaded application in which I have 3 threads running including main thread. One of the thread (Thread1) spawned by main thread is performing the business logic required. The other one (Thread 2) is just to send the periodic signals to an admin application that it is alive. Now I need to pass some data obtained from business logic (Thread1) to the second thread (Thread2). How can i do that.? I need the data from Thread1 to Thread2 every time, the thread2 send the alive request to admin application.
Thanks & Regards
Inder Jeet Singh
Advertisement
The best answer: See Producer/Consumer example at for 2 threads exchanging data:
http://java.sun.com/docs/books/tutorial/essential/threads/synchronization.html
In your case it seems reasonable to store data somewhere until T2 will use it during sending
alive request to admin application