java怎么编写一个线程
收起
云计算小粉
2018-05-10 20:09:15
1966
0
1
条回答
写回答
取消
提交回答
-
public class DoubleThread {
public static void main(String[] args) {
Thread t1 = new Thread() {
@Override
public void run() {
for (char i = 'a'; i <= 'z'; i++) {
System.out.println(i);
}
}
};
Thread t2 = new Thread() {
@Override
public void run() {
for (char i = 'A'; i <= 'Z'; i++) {
System.out.println(i);
}
}
};
t1.start();
t2.start();
}
}
2019-07-17 22:18:33