Back
Close

Computing with Data

elgeish
178.4K views

The Producer-Consumer Problem - Part VI

The following program fixes the deadlock issue and works correctly:

import java.util.ArrayDeque;
import java.util.Queue;
class Shared {
private static final int MAX_BUFFER_SIZE = 3;
private static Queue<String> buffer = new ArrayDeque<>();
private static final Object lock = new Object();
static String remove() throws InterruptedException {
final String message;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants