📄 lockdemo.java
字号:
//==============================================================
// LockDemo.java - Demonstrate object locks and synchonization
//
// Java学习源代码检索系统 Ver 1.0 20031015 免费正式版
// 版权所有: 中国IT认证实验室(www.ChinaITLab.com)
// 程序制作: ChinaITLab网校教研中心
// 主页地址: www.ChinaITLab.com 中国IT认证实验室
// 论坛地址: bbs.chinaitlab.com
// 电子邮件: Java@ChinaITLab.com
//==============================================================
import java.io.IOException;
import java.util.*;
import Client;
class LockDemo {
// Get a character from keyboard
static char getChar() {
char ch = '\0';
try {
ch = (char)System.in.read();
} catch (IOException e) {
System.out.println(e.getMessage());
}
return ch;
}
// Wait for user to press a specified key
static void waitForKey(char key) {
while (getChar() != key) /* wait */ ;
}
public static void main(String args[]) {
// Construct and start the client (job creator) thread
Client client = new Client();
new Thread(client).start();
// Wait for Enter key so threads can run
System.out.println("\n<<< Press Enter to end program >>>\n");
waitForKey('\n'); // All threads run while waiting
// Halt the client thread; sever daemon also ends
// However, any remaining job threads finish to completion!
client.halt();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -