public class Demo43 {
/*
* 项目下有个xxx.txt文件,里面存了十个小朋友的名字,开始两个线程,每隔两秒执行一次,十个小朋友去打疫苗
* 窗口A和窗口B交替执行,打印结果为小明在窗口A打疫苗
*/
public static void main(String[] args) {
final Vaccinum v = new Vaccinum();
new Thread("窗口A") {
public void run() {
try {
v.vac1();
} catch (Exception e) {
}
}
}.start();
new Thread("窗口B") {
public void run() {
try {
v.vac2();
} catch (Exception e) {
}
}
}.start();
}
}
class Vaccinum {
private static int num = 0;
private int falt = 1;
public void vac1() throws Exception {
ArrayList<String> list = getList();