Pause thread in java

Source code below will print hi after pause for 5 seconds.

********************************************************
COMPLETE SOURCE CODE FOR : ThreadPause.java
********************************************************


public class ThreadPause extends Thread
{
public void run()
{
//Pause thread for 5 seconds before print hi
try
{
sleep(5000);
}
catch(Exception exception)
{
exception.printStackTrace();
}

//Print hi
System.out.println("hi");
}

public static void main(String[]args)
{
//Create a thread by create ThreadPause object
ThreadPause a=new ThreadPause();

//Start the thread
a.start();
}
}


********************************************************
JUST COMPILE AND EXECUTE IT
********************************************************
Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You