hi shalini,
after the statement t1.start(); is executed
the run method in Slave class gets executed by the thread t1 whereas your main thread is looping continuously here:
while(bContinue==false)
{
}
because both run() and setPrice() are synchronized methods of the same class if any thread enters one of the methods automatically all synchronized methods of that object ("s object" here) are locked by that thread which means no other thread(main thread here) can enter the synchronized methods using the same "object s".
now the thread t1 sets the value of master.bContinue to true(master.bContinue=true
so the main thread comes out of the above while loop and tries to execute
s.setPrice(200);
but remember out little s objects' synchronized method setPrice() is locked by the thread t1 in the run method and looping infinitely here:
while(true){
System.out.println(iPrice);
}
So the thread t1 will be in the running state forever and never gives up the s objects' lock while the main thread will be in runnable state for eternity.