import java.io.*;

public class MyClass
{
	static boolean done=false;
	public static void main(String argv[])
	{
		MyThread threadA=new MyThread(0);
		MyThread threadB=new MyThread(1);
		System.out.println(" starts two threads");
		threadA.start();
		
		threadB.start();
			
		System.out.println(" two threads started");
	}


	static synchronized void funcA()
	{
		try
		{
			while (!done)
			{
				System.out.println("done is false and sleep...");
				Thread.sleep(1000);
			}
		}
		catch(Exception er)
		{
		}
	}

	static synchronized void funcB()
	{
		System.out.println("I never reach here!");
		done=true;
	}	

	static class MyThread extends Thread
	{
		int myID;
		public MyThread(int id)
		{
			myID=id;
		}
		public void run() 
		{
			if (myID==0)
			{
				funcA();
			}
			else
			{
				funcB();
			}
		}
	}
			
}	

