package com.lovecoding.day14.ex01;

//两个线程的通信
public class PrintLetter1 {

    private static char letter = 'a';


    //输出小写
    public synchronized void printLower() throws InterruptedException {
        //输出
        for (int i = 1; i <=3 ; i++) {
            System.out.println( Thread.currentThread().getName()+"：" + (char)(letter++));
            if (letter> 'z'){
                letter = 'a';
            }
        }
        //通知
        notify();
        //等待
        wait();
    }

    //输出大写  -32
    public synchronized void printUpper() throws InterruptedException {

        //输出、
        for (int i = 1; i <= 3; i++) {
            System.out.println( Thread.currentThread().getName()+"：" + (char) (letter++ -32));
            if (letter> 'z'){
                letter = 'a';
            }
        }
        //通知
        notify();
        //等待
        wait();
    }


}
