• Post Reply Bookmark Topic Watch Topic
  • New Topic

competing to get the control on object monitor in synchronized vs wait

 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
synchronized(this) {
try {
this.wait(5 * 60 * 1000); // wake up every 5min
} catch (InterruptedException e) {}
}
If some threads are waiting to get the control on this object at the synchronized and others threads in the wait set are notified, thread from which queue has higher priority to enter the critical section?
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which object gets the lock back is undefined and may be non-deterministic. Assuming that a certain thread will ever clear a pool of threads waiting for the same lock if it waits long enough is potential source of thread starvation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!