日期:2014-05-20 浏览次数:20775 次
package cn.xujin;
public class X implements Runnable{
private int x;
private int y;
public static void main(String[] args){
X that =new X();
X other = new X();
X theOther = new X();
System.out.println("0");
(new Thread(that)).start();
System.out.println("1");
(new Thread(other)).start();
System.out.println("2");
(new Thread(theOther)).start();
String s1 = "d";
String s2 = "222";
String s = s1 + s2;
System.out.println("over");
}
public synchronized void run(){
for(;;){
x++;
y++;
System.out.println("x="+x+",y="+y + " " + Thread.currentThread().getName());
if(x > 10) break;
}
}
}