jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread Watch "thread New topic


nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
If we have 4 thread's executing 4 synchronized method's ,Three in the waiting state and one in running state,out of those three in the waiting state, two with high priority and the third one with the low priority and low priority thread is the first to go in the waiting state when we call notify() then which thread will start running first.

Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Your scenario has many complications that are not explained. Are the 4 methods that are synchronized in the same class?? Is the synchronized code synchronized on a method, a block, a static method??? What is the priority of the running thread compared to the other 3, etc. etc.

"JavaRanch, where the deer and the Certified play" - David O'Meara

Joined: Feb 15, 2001
Posts: 11
Hi Nitin,
there is no way u can predict which thread comes out waiting state first and goes into ready state.
if u 've called notifyAll() all the 3 threads will go to ready
I hope this helps u.
subject: thread's
It's not a secret anymore!