Java program for Runnable interface
KW.java
class KW implements Runnable
{  
    public void run()
    {  
        System.out.println("Thread Running...");  
    }  
    public static void main(String args[])
    {  
        KW k=new KW();
        Thread t1=new Thread(k); 
        //t1.run();  
        System.out.println(t1.isAlive()); 
        t1.start(); 
        System.out.println(t1.isAlive());
    }  
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW false true Thread Running... kodingwindow@kw:~$
Advertisement