Java program to perform a single task by multiple threads
KW.java
class KW extends Thread
{  
    public void run()
    {  
        System.out.println("Thread Running...");  
    }  
    public static void main(String args[])
    {  
        KW t1=new KW();
        KW t2=new KW(); 
        t1.start();
        t2.start(); 
    }  
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Thread Running... Thread Running... kodingwindow@kw:~$
Advertisement