purpose of this application is to create a multi-threaded application with one thread being a producer of playing cards and another thread being a consumer of playing cards. the application will run with the welcome to war greeting : here is an example of what it should look like . The buffer will be based on the SynchronizedBuffer but will store a Card instead of an int. The producer will produce a playing card having a random value of either 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Ace. The producer will put that randomly created card in the buffer. Afterward, the producer will sleep randomly between 1-4 seconds before producing another card. The consumer will get 2 cards from the buffer. Once the consumer has 2 cards, it will use them to simulate the card game WAR. The consumer will compare the cards and print the winner. Afterward, the consumer will sleep randomly between 1-4 seconds before consuming cards and simulating the game again. Both producer and consumer will run forever. This means the output of the game will never end – the game will play forever. run: Welcome to WAR Producer has started running Consumer has started running Producer produced 5 Buffer empty. Consumer waits. Producer produced 2 PLAY GAME Card 1 is "5", Card 2 is "2". Winner is Card 1 Buffer empty. Consumer waits. Producer produced 3 Buffer empty. Consumer waits. Producer produced 4 PLAY GAME Card 1 is "3", Card 2 is "4". Winner is Card 2 Buffer empty. Consumer waits. Producer produced 5 MORE VIDEOS pty. Consumer waits.. run: Welcome to WAR Producer has started running Consumer has started running Producer produced 5 Buffer empty. Consumer waits. Producer produced 2 PLAY GAME Card 1 is "5", Card 2 is "2". Winner is Card 1 Buffer empty. Consumer waits. Producer produced 3 Buffer empty. Consumer waits. Producer produced 4 PLAY GAME Card 1 is "3", Card 2 is "4". Winner is Card 2 Buffer empty. Consumer waits. Producer produced 5 MORE VIDEOS pty. Consumer waits..
-
Engineering 2022-05-15 19:04:59