在千峰第28天
“精诚所至”
中国加油,武汉加油,千峰加油,我自己加油。
Q12
1、单核CPU在任何时间点上,只能运行一个进程,宏观并行、微观串行
2、C
3、C
4、A
5、
public class Test {
public static void main(String[] args) {
MyThread t1 = new MyThread();
Thread t2 = new Thread(new MyRunnable());
t1.start();
t2.start();
}
}
class MyThread extends Thread{
public void run() {
for (int i = 0; i < 100 ; i++) {
for(int j = 1 ; j <= 26 ; j++) {
System.out.println(j);
}
}
}
}
class MyRunnable implements Runnable{
@Override
public void run() {
for (int i = 0; i < 100 ; i++) {
for(int j = 65 ; j <= 90 ; j++) {
System.out.println((char)j);
}
}
}
}
6、
①保障线程安全
②输出顺序会随机,$$$和###可能会交替出现
7、
C