PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 19, 2022

[FIXED] How to solve a "1 producer 2 consumers" problem in java

 September 19, 2022     buffer, consumer, java, producer     No comments   

Issue

I am pretty new in writing Java and i'm currently trying to implement a different aspect of the classic "Producer-Consumer" problem. I still use one Producer like usual, who writes strings in a buffer. This buffer is shared with the 2 Consumer threads, and what I am trying to do is to have both the Consumers pick up EVERY string the producer sends, and ONLY then delete the string from the buffer. How can i check if both the Consumer threads have already taken the string??? Thank you!


Solution

Maybe you can use the observer pattern.

More info: https://www.baeldung.com/java-observer-pattern



Answered By - Wellington Zomer Nunes
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing