Skip to content

生产者-消费者模型#197

Open
hahaen wants to merge 2 commits into
masterfrom
haha
Open

生产者-消费者模型#197
hahaen wants to merge 2 commits into
masterfrom
haha

Conversation

@hahaen

@hahaen hahaen commented Sep 28, 2021

Copy link
Copy Markdown
  • 这个PR解答了当前仓库中的题目(机器人会自动判题并合并当前PR)
  • 这个PR修复了当前仓库中的一些代码缺陷(机器人不会判题,而是由管理员来处理当前PR)

@hcsp-bot

Copy link
Copy Markdown
Contributor

🎉 感谢提交Pull Request!请稍等片刻,我们已经将其提交到CI进行检查,一旦有结果会立即通知您!

}
}
Integer value = container.getValue().get();
System.out.println("Consumer:"+value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 后应有空格。
'+' 前应有空格。

@@ -1,24 +1,70 @@
package com.github.hcsp.multithread;

import java.util.Optional;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用导入 - java.util.Optional 。

import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.locks.Condition;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用导入 - java.util.concurrent.locks.Condition 。

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用导入 - java.util.concurrent.locks.ReentrantLock 。

public static void main(String[] args) throws InterruptedException {
BlockingQueue<Integer> queue = new LinkedBlockingDeque<>(1);
BlockingQueue<Integer> signalQueue = new LinkedBlockingDeque<>(1);
Producer producer = new Producer(queue,signalQueue);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

',' 后应有空格。

BlockingQueue<Integer> queue = new LinkedBlockingDeque<>(1);
BlockingQueue<Integer> signalQueue = new LinkedBlockingDeque<>(1);
Producer producer = new Producer(queue,signalQueue);
Consumer consumer = new Consumer(queue,signalQueue);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

',' 后应有空格。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants