public class ThreatDemo{
public ThreatDemo(){
}
public static void main(String args[]){
Runnable printA = new PrintChar('A', 100);
Runnable printB = new PrintChar('B', 100);
Runnable printC = new PrintChar('C', 100); Thread thread1 = new Thread(printA);
Thread thread2 = new Thread(printB);
Thread thread3 = new Thread(printC); thread1.start();
thread2.start();
thread3.start();
}
}
class PrintChar implements Runnable{
private int time;
private char ch;
public PrintChar(char ch1,int time1){
this.time = time1;
this.ch = ch1;
}
public PrintChar(){
}
public void run(){
for(int i=0;i<time;i++)
System.out.print(ch);
}
}
用上面的代码,debug出结果怎么不会是 ABCABCABC... 而是AAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBBBBBAAAAAAAAAAAA...
这样的形式?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货