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().