62,621
社区成员
发帖
与我相关
我的任务
分享
public class Cs{
String mob = null;
String u = null;
public moder(String mobel,String user){
mob=mobel;
u=user;
}
}
public class TestSynch implements Runnable {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 1000; i++) {
TestSynch ts1 = new TestSynch("us", "111");
TestSynch ts2 = new TestSynch("ch", "222");
new Thread(ts1).start();
new Thread(ts2).start();
}
}
public static cs c;
public String country;
public String code;
public TestSynch(String country, String code) {
c = new cs();
this.country = country;
this.code = code;
}
@Override
public void run() {
// TODO Auto-generated method stub
c.moder(country, code);
}
}
class cs {
String country = null;
String code = null;
public void moder(String country, String code) {
this.country = country;
for (int i = 0; i < 1000000; i++) {
}
;
this.code = code;
if ((this.country.equals("us") && this.code.equals("222"))
|| (this.country.equals("ch") && this.code.equals("111"))) {
System.out.println(this.country + "," + this.code);
}
}
}