Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

wait() and notify() methods ragarding threads.  RSS feed

dolly bhawsar
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().

Dolly Bhawsar
sushil grover
Posts: 12
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!