-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
the example of that question is on java and not on golang
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
public class BatchDataTransfer {
public static void main(String[] args) {
BlockingQueue channel = new ArrayBlockingQueue<>(5);
// Producer
new Thread(() -> {
for (int i = 0; i < 100; i++) {
try {
channel.put(i);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}).start();
// Consumer
new Thread(() -> {
while (true) {
try {
System.out.println(channel.take());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}).start();
}
}
Metadata
Metadata
Assignees
Labels
No labels