• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronization - cannot wake a sleeping thread?

 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'notify' will make runnable a waiting thread, but a sleeping thread will always sleep it's time?
There is no method to wake a sleeping thread?

thank you
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. It's late. I'm going to bed now
 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:Never mind. It's late. I'm going to bed now


Good plan! I think I should also - think with new head tomorrow!
 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nigel Shrin wrote:'notify' will make runnable a waiting thread, but a sleeping thread will always sleep it's time?
There is no method to wake a sleeping thread?

thank you


Ah - might have found the answer:
you can use an interrupt(), but have to handle/declare an interrupt exception

Is that right?!

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
notify() and notifyAll() methods will notify the Threads, which are waiting for execution, in the pool. I think it's correct thet we can call interrupt() method to interrupt that sleeping thread. But don't have any example coding!
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:notify() and notifyAll() methods will notify the Threads, which are waiting for execution, in the pool. I think it's correct thet we can call interrupt() method to interrupt that sleeping thread. But don't have any example coding!

Waiting and sleeping are two different things. notify and notifyAll won't wake up a sleeping thread. Only the interrupt method can be used to wake a sleeping thread...
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea! Thanks Ankit!
 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Abimaran & Ankit for the clarification - much appreciated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic