• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a Thread Q

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
" Calling the wait/ notify /NotifyAll method on an object CAN directly cause a thread to stop executing" ---I can understand calling the wait() can cause a thread to stop executing ,yet,"What notify() does is to arbitrarily select one of the threads into the monitor's waiting pool and move it to the Seeking Lock State.".How can I understand calling the notify() can cause a thead to stop executing?
Thanks!
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Lin:
" "What notify() does is to arbitrarily select one of the threads into the monitor's waiting pool and move it to the Seeking Lock State.".How can I understand calling the notify() can cause a thead to stop executing?
Thanks!


You have already answered the question. A waiting thread might start executing and the thread that called notify would then move out of the running state.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The waiting thread is not able to start execution untill the lock is freed. This happens only when the thread that called notify completes the synchronized block/method.
reply
    Bookmark Topic Watch Topic
  • New Topic