        // Illustrate the setting of a priority on a newly
        // created thread.
public class PriorityExample {
    public static void main(String[] args){
        // Create the runnable object.
        Runnable counter = new GreedyCounter();
        // Pass the runnable object to a new thread.
        // Give the thread a name.
        Thread secondThread = new Thread(counter,"counter");

        if(!secondThread.isAlive()){
            System.out.println("Second thread is not yet alive.");
        }
        // Modify the new thread's priority to be greater than
        // this threads.
        Thread myThread = Thread.currentThread();
        secondThread.setPriority(myThread.getPriority()+1);

        secondThread.start();
        if(secondThread.isAlive()){
            System.out.println("Second thread is now alive.");
        }
        // Let secondThread have a go.
        Thread.yield();
        if(!secondThread.isAlive()){
            System.out.println("Second thread is no longer alive.");
        }
        System.out.println("First thread has finished.");
    }
}

