两个线程、一个输出字母一个输出数字。交替输出:1A2B3C……

static Thread t1=null,t2=null;
public static void main(String[] args)throws Exception {
char[] aI = “1234567”.toCharArray();
char[] aC = “ABCDEFG”.toCharArray();
t1=new Thread(()->{
for (char c : aI) {
System.out.println?;
LockSupport.unpark(t2);
LockSupport.park();
}
},“t1”);

t2=new Thread(()->{ for (char c : aC) { LockSupport.park(); System.out.println(c); LockSupport.unpark(t1); } },"t2"); t1.start(); t2.start();

【两个线程、一个输出字母一个输出数字。交替输出:1A2B3C……】}

    推荐阅读