Multithreading Example in Java

package multithreading;
import java.io.*;
public class Multithreading
{
public static void main(String[] args)
{
mthread thread1 = new mthread(“piit”);
mthread thread2 = new mthread(“new panvel”);
thread1.start();
thread2.start();
}
}
class mthread extends Thread
{
String a;
public void run()
{
for(int i=0;i<=3;i++) { System.out.println(" "+a); try { Thread.sleep(500); }catch(Exception e){}; } } mthread(String b) { a=b; } } [/java]

Leave a Reply

Your email address will not be published. Required fields are marked *