Java 7일차 Thread 테스트

public class ThreadTest extends Thread
{
String name;

public void run()
{
try
{
for(int i=0; i<10; i++)
{
Thread.sleep(10);
System.out.println(name+" "+i);
}
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}

public ThreadTest(String data)
{
name = data;
}

public static void main(String[] args)
{
ThreadTest tt1 = new ThreadTest("1번");
ThreadTest tt2 = new ThreadTest("2번");
ThreadTest tt3 = new ThreadTest("3번");

tt1.start();
tt2.start();
tt3.start();
}
}

댓글 없음: