Hi
To create Multiple thread by implement runnable interface in java
Code:
To create Multiple thread by implement runnable interface in java
Code:
public class Threadtest implements Runnable{
public static void main(String [] args)
{
Threadtest t= new Threadtest();
Thread t1= new Thread(t);
Thread t2=new Thread(t);
Thread t3= new Thread(t);
t1.setName("kumud1");
t2.setName("kumud2");
//t3.setName("kumud3");
t1.start();
t2.start();
//t3.start();
}
public void run() {
for (int a=0; a<4;a++)
System.out.println("The Current Thread is"+Thread.currentThread().getName());
try{
Thread.sleep(5*60*1000000000);
}
catch(Exception ex)
{
}
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.