File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread's

 
nitin sharma
Ranch Hand
Posts: 290
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ASHISH KUMAR
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
state.
I hope this helps u.
bye
ashish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic