• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why thread priority is not working here

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i ran tis program for many times but it is not displaying according to threads priority?
why?
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by saikrishna cinux:

i ran tis program for many times but it is not displaying according to threads priority?
why?


Well I run this program on my m/c I got output according to the expectaions. I am giving here output on my m/c

Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]


Well I think it's according to your expectations, what you was expecting could you let me know.....

according to your code..



th2 is with MAX_PRIORITY
th3 is then and at last is
th1
[ September 26, 2006: Message edited by: Ankur Sharma ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While a thread sleeps, other threads are allowed to execute. Priority only comes into play when two threads try to do something at the same time, which is not guaranteed to happen at all for our example.

Moving to our threads forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic