System.in的用法
方法1
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner scanner=new Scanner(System.in);
String inputStr=null;
try {
// while ((inputStr = br.readLine())!=null) {
while ((inputStr = scanner.next())!=null) {
mychat.sendMessage(inputStr);
}
}catch (Exception ex){}
方法2: while(true);
方法3:object.wait ( 获取锁后)