实验目的:
掌握使用Thread的子类创建线程的方法
Main.java
public class Main {
public static void main(String[] args) {
System.out.println("键盘练习(输入#结束程序)");
System.out.printf("输入显示的字母(回车)\n");
Letter letter;
letter=new Letter();
GiveLetterThread giveChar;
InputLetterThread typeChar;
giveChar=new GiveLetterThread();
giveChar.setLetter(letter);
giveChar.setSleepLength(3200);
typeChar=new InputLetterThread();
typeChar.setLetter(letter);
giveChar.start();
typeChar.start();
}
}
Letter.java
public class Letter {
char c='\0';
public void setChar(char c){
this.c=c;
}
public char getChar(){
return c;
}
}
InputLetterThread.java
import java.awt.*;
imp