Redian新闻
>
java synchronized 问题 (转载)
avatar
java synchronized 问题 (转载)# Java - 爪哇娇娃
j*g
1
【 以下文字转载自 Programming 讨论区 】
发信人: joking (看一看), 信区: Programming
标 题: java synchronized 问题
发信站: BBS 未名空间站 (Tue Dec 11 16:18:47 2007)
今天看programer_interview看到一个producer-customer并行的问题,用java写的(第7
章section 7.12). Program is written as:
class producer extends Thread {
......
void run() {
while (true) {
try {
putInt();
}
catch (...){};
}
}
private synchronized void putInt() throws ... {
while (index == MAX_CAPACITY) {
wait()
}
buffer[ind
avatar
m*t
2
Whatever thread(s) stuck in putInt won't be able to proceed right away. They
would have to wait until the notifier thread exits getInt and releases the
lock.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。