Write a java program to display message a 2sec time gap using runnable interface

Write a java program to display message a 2sec time gap using runnable interface

Program
class ThDemo implements Runnable
{
    public void run()
    {
        int x;
        try
        {
            for(x=1;x<=10;x++) 
            {
                Thread.sleep(2000);
                System.out.println("Hello Sateesh");
            }
                	
        }
        catch(Exception e)
        {
            System.out.println(e);
        } 
    }
}
public class Main
{
    public static void main(String args[])
    {
        ThDemo d=new ThDemo();
        Thread t=new Thread(d);
        t.start();
    }
}


Output:

Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh
Hello Sateesh


Multi Threading In Java



More Questions


213 . Write a Java-program to Count the number of spaces in a given string
214 . Write a Java-program to Count the number of special characters in a given string ?
215 . Write a Java-program to Count the number of letters in a given string ?
216 . Write a Java-program to Count the number of Numbers in a given string ?
217 . Write a Java-program to Remove vowels in a given string ?
218 . Write a Java-program to Remove consonants in a given string ?
219 . Write a Java-program to Remove special characters in a given string ?
220 . Write a Java-program to Remove spaces in a given string ?
221 . Write a Java-program to Remove letters in a given string ?
222 . Write a Java-program to Remove numbers in a given string ?
223 . Write a Java-program to print duplicate characters from the string ?