//===============================================================
// Using thread priority
// MIN_PRIORITY = 1, MAX_PRIORITY = 10, NORM_PRIORITY = 5  
//===============================================================
public class Priority
{
    public static void main(String[] args)
    {
        Thread t1 = new PriorityOdd();          //instantiate a thread 
        Thread t2 = new PriorityEven();             

        t1.setPriority(Thread.MIN_PRIORITY);    //setting priority other than norm
        t2.setPriority(Thread.MAX_PRIORITY);

        t1.start();                             //make it eligible for the scheduler to run it
        t2.start();                         
    }
}

class PriorityOdd extends Thread
{
    public void run( )
    {
        for (int odd = 1; odd <= 1000; odd += 2)
        {
            System.out.println( this.getName( ) + " - count: " +  odd);
        }                                 
    }
}

class PriorityEven extends Thread
{
    public void run( )
    {
        for (int even = 2; even <= 1000; even += 2)
        {
            System.out.println("\t\t\t" + this.getName( ) + " - count: " +  even);
        }
    }
}