public class ThreadTest2 implements Runnable
{
String name;
public void run()
{
try
{
for(int i=0 ; i<5 ; i++)
{
Thread.sleep(300);
System.out.println(name + i);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public ThreadTest2(String data)
{
name = data;
}
public static void main(String[] args)
{
ThreadTest2 tt1 = new ThreadTest2("1번");
ThreadTest2 tt2 = new ThreadTest2("2번");
ThreadTest2 tt3 = new ThreadTest2("3번");
new Thread(tt1).start();
new Thread(tt2).start();
new Thread(tt3).start();
}
}
댓글 없음:
댓글 쓰기