创建两个线程,其中一个输出1-52,另外一个输出A-Z。输出格式要求:12A 34B 56C 78D
public class Try {
public static void main(String[] args) {
Object o = new Object();
Number number = new Number(o);
Word word = new Word(o);
Thread thread = new Thread(number);
Thread thread2 = new Thread(word);
//这两个人得用一个锁对象,才能达到唤醒的效果?
thread.start();
thread2.start();
}
}
class Number implements Runnable{
private Object obj;
public Number(Object obj) {
//给一个传入锁的构造方法
this.obj = obj;
}
@Override
public void run() {
synchronized (obj){
for