*
The moose likes Threads and Synchronization and the fly likes why thread priority is not working here Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "why thread priority is not working here" Watch "why thread priority is not working here" New topic
Author

why thread priority is not working here

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689


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


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

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 ]

The Best way to predict your future is to create it - Every great individual common man
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why thread priority is not working here
 
Similar Threads
Thread question
join()
Exeptions with Threads
Threads
thread priority