Amazon Affiliate

Tuesday 27 March 2012

SET PRIORITY OF THREAD IN JAVA..


//Techniques to set priority

//Create Threads Object First

// Suppose Thread Objects are th1,th2 and th3

//then

         th1.setpriority(Thread.NORM_PRIORITY);// here we select Norm priority
         th2.setpriority(Thread.NORM_PRIORITY+1);// Norm priority increase by 1
         th3.setpriority(Thread.NORM_PRIORITY+2);// Norm priority increase by 2    

// now start Threads
         th1.start();
         th2.start();
         th3.start(); 

// you can also set priority like MAX_PRIORITY and MIN_PRIORITY


No comments:

Post a Comment