同時練習1
2008 ワード
package threadtest;
/**
*
* @author Administrator
*/
public class ThreadTest {
/**
* @param args the command line arguments
*/
public static class exercise implements Runnable
{
//
private int count ;
public exercise(){}
public exercise(int count)
{
this.count = count;
System.out.println("exercise"+count+" had been constructed");
}
public void run()
{
for(int i = 0;i < 3;i++)
{
System.out.println("now in thread"+ i+" times");
Thread.yield();
}
System.out.println("end " + count);
}
}
public static void main(String[] args) {
// TODO code application logic here
for(int i=0; i<5; i++)
{
new Thread(new exercise(i)).start();
}
}
}