• 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

Dilemma about wait(timeout) and notify

 
Greenhorn
Posts: 2
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what happens if I have thread which waits on
for example and someone calls notifyAll() from another synch method.

Do thread continue waiting till the time is lapse then is woke up or notifyAll() wakes them up regardlessly of time which is not yet elapsed???

Thanks.

 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you notify it wakes up before the timeout but note it can wake up spuriously also read this ..
wait
 
Ranch Hand
Posts: 300
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
timeout will only come in picture if notify() or notifyAll() is not called otherwise Thread can woke up even before timeout.

Its also worth noting that :

1) Wait should always be called from synchronized context
2) Wait should always be called from inside loop
 
reply
    Bookmark Topic Watch Topic
  • New Topic