由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个JAVA程序请教
相关主题
给大家出个多进程的题重复利用threads的问题
求教一个Java问题 IllegalMonitorStateException如何查看一个程序/进程使用了哪些cpu?
请教一个concurrentlinkedqueue的用法问题请问一个c++结果显示的问题
请教pthread producer-consumer问题学python要学到什么程度才算professional?
现在082KAFKA支持produce数组吗C# thread
java producer consumer problem (转载)java synchronized 问题
Re: java producer consumer problem (转载)[合集] 这个问题怎么解效率最高
Kafka consumer启动怎样不读之前的massagetypeid produces a reference to a static type_info
相关话题的讨论汇总
话题: cubbyhole话题: producer话题: thread话题: 程序话题: extends
进入Programming版参与讨论
1 (共1页)
m********x
发帖数: 176
1
主要是学习线程的用法,这个程序是简单的生产一个就取走一个。但是现在的程序好像
只能产不能去。球各位老师指正。
class Producer extends Thread{
private CubbyHole cubbyhole;
public Producer(CubbyHole c){
cubbyhole=c;
}
public void run(){
for(int i=0; i<5; i++){
cubbyhole.put(i);
System.out.println("Producer put:"+i);
try{
sleep((int)(Math.random()*100));
}
catch(InterruptedException e){
}
}
}
}
class Consumer extends Thread
q*****t
发帖数: 3
2
Put these three lines after the while loops:
seq=value;
available=true;
notify();
All the producers have never gone into the while loops
because the initial value of available is false. Customers
have never been notified.
m********x
发帖数: 176
3
Thanks a lot. It works
1 (共1页)
进入Programming版参与讨论
相关主题
typeid produces a reference to a static type_info现在082KAFKA支持produce数组吗
对pthread熟悉的XD请进来看看java producer consumer problem (转载)
没有java命令怎么执行jar文件阿? (转载)Re: java producer consumer problem (转载)
Re: 一道count frequency of all words的面试题 (转载)Kafka consumer启动怎样不读之前的massage
给大家出个多进程的题重复利用threads的问题
求教一个Java问题 IllegalMonitorStateException如何查看一个程序/进程使用了哪些cpu?
请教一个concurrentlinkedqueue的用法问题请问一个c++结果显示的问题
请教pthread producer-consumer问题学python要学到什么程度才算professional?
相关话题的讨论汇总
话题: cubbyhole话题: producer话题: thread话题: 程序话题: extends