该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public class Z extends Thread{
char[] letters = new char[]{'a','b','c','d','e','f','g','h','i','j','k'
,'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
public static void main(String[] args){
Z z = new Z();
X x = new X();
x.start();
z.start();
}
public void run() {
for(int i = 0;i
System.out.println("letter:"+this.letters[i]);
if(i%2!=0){
try {
this.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
class X extends Thread{
int[] nums = new int[26];
public X(){
for(int i=0;i
this.nums[i] = i+1;
}
}
public void run() {
for(int i = 0;i
System.out.println("num:"+this.nums[i]);
if(i%2!=0){
try {
this.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}