Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void produceConsume() {
- try {
- Thread producer = new Thread(new Runnable() {
- //actual implementation omitted
- });
- producer.start();
- List<Thread> consumers = new ArrayList<>();
- for (int i = 0; i < noOfThreads; i++) {
- Thread consumer = new Thread(new Runnable() {
- //actual implementation omitted
- });
- consumer.start();
- consumers.add(consumer);
- }
- for (Thread t : consumers) {
- t.join();
- }
- producer.join();
- } catch (Exception e) {
- LOG.error("InterruptedException e: " + e.getMessage(), e);
- } finally {
- LOG.info("We are done with this file!");
- }
- }
Add Comment
Please, Sign In to add comment