aspose file tools*
The moose likes Threads and Synchronization and the fly likes wait() and notify() methods ragarding threads. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "wait() and notify() methods ragarding threads." Watch "wait() and notify() methods ragarding threads." New topic
Author

wait() and notify() methods ragarding threads.

dolly bhawsar
Greenhorn

Joined: Feb 19, 2010
Posts: 3
i want to know how should i implement, if i have two threads waiting on a bunch of code to be complete.

just for an simple example: if i have write a function to calculate sum of few integers and after performing this sum i m displaying that amount.
finally i want that one thread perform this sum() and another print it,,so i want that while executing the sum() through one thread another would wait for it's completion.

please someone tell me the code for implementing above, so that i can clearly understand the basic idea of wait and notify. i m confused in terms of when to wait, for which object i have to use wait(), and when and for which thread i have to use notify().

Regards:
Dolly Bhawsar
sushil grover
Greenhorn

Joined: Nov 28, 2008
Posts: 12
you can refer to the post given below:-

http://www.coderanch.com/t/417985/Programmer-Certification-SCJP/certification/Threads-notify-wait

 
 
subject: wait() and notify() methods ragarding threads.