<<< Creating a thread implementing Runnable interface | Index | Starting Runnable interface thread example >>> |
public class IOTask implements Runnable
{
@Override
public void run()
{
Thread ct = Thread.currentThread();
System.out.println( ct.getName() + " started" );
try
{
// Sleep for 2 seconds to simulate an IO task
// that takes a long time
Thread.sleep( 2000 );
}
catch( InterruptedException ex )
{
}
System.out.println( ct.getName() + " finished" );
}
}
<<< Creating a thread implementing Runnable interface | Index | Starting Runnable interface thread example >>> |