黑马程序员技术交流社区
标题:
请问各位前辈这样的话返回语句怎么写
[打印本页]
作者:
白萝卜
时间:
2017-5-28 13:46
标题:
请问各位前辈这样的话返回语句怎么写
public void put(Object x) throws InterruptedException {
if (isok && count == 0) {
isok = false; // 可以第一次执行生产
}
if (!isok) {
lock.lock();
try {
while (count == items.length)
notFull.await();
items[putptr] = x;
if (++putptr == items.length)
putptr = 0;
++count;
System.out.println(Thread.currentThread().getName() + "...生产者5.0..." + count);
if (count == items.length)
notEmpty.signal();
} finally {
lock.unlock();
}
}
}
public Object take() throws InterruptedException {
if (!isok && count == items.length) {
isok = true; // 可以第一次执行消费
}
if (isok) {
lock.lock();
try {
while (count == 0)
notEmpty.await();
Object x = items[takeptr];
if (++takeptr == items.length)
takeptr = 0;
--count;
System.out.println(Thread.currentThread().getName() + "...消费者5.0..." + count);
if (count == 0)
notFull.signal();
} finally {
lock.unlock();
}
}
}
//定义了多线程,一个线程执行输出任务,另一个线程执行的是输入的任务,需求是,在输入5000之前不要输出,也不要返回,已经控制了输出,返回语句怎么写啊。。。
作者:
白萝卜
时间:
2017-5-28 13:49
自己顶,不要沉啊
作者:
白萝卜
时间:
2017-5-28 13:50
不要沉不要沉啊
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2