Wednesday, January 15, 2014

Example of synchronized method by implementing Runnable

class Thread18 implements Runnable
{
public void run()
{
Thread t = Thread.currentThread();
System.out.print(t.getName());
System.out.println(", status = " + t.isAlive());
}
public static void main(String surat[]) throws Exception
{
Thread t = new Thread(new Thread18());
t.start();
t.join();
System.out.print(t.getName());
System.out.println(", status = " + t.isAlive());
}
}

Output:

No comments:

Post a Comment