package action;

class Tmp
{
boolean b;

public boolean isB() {
return b;
}

public void setB(boolean b) {
this.b = b;
}

}

class Alpha implements Runnable
{
Tmp o;

public Alpha(Tmp o)
{
this.o=o;

}

@Override
public void run() {


for(int i='A';i<='Z';i++)
{

try {
synchronized(o)
{

while(o.b==false)
{
try {
o.wait();
} catch (InterruptedException e) {

e.printStackTrace();
}
}
System.out.println((char)i);

o.b=false;

o.notify();


}



} catch (Exception e) {

e.printStackTrace();
}
}


}

}

class Num implements Runnable
{
Tmp o;

public Num(Tmp o)
{
this.o=o;

}

@Override
public void run() {

for(int i=1;i<=26;i++)
{


try {

synchronized(o)
{
while(o.b==true)
{
try {
o.wait();
} catch (InterruptedException e) {

e.printStackTrace();
}
}

System.out.println(i);
o.b=true;
o.notify();

}
} catch (Exception e) {

e.printStackTrace();
}
}


}

}

public class Test01 {
static Tmp o=new Tmp();

public static void main(String[] args) throws InterruptedException {
Thread t1=new Thread(new Alpha(o),"t1");
Thread t2=new Thread(new Num(o),"t2");
t1.start();
t2.start();
t1.join();
t2.join();
System.out.println("All over.");


}

}