Skip to content

Commit dca6b37

Browse files
committed
Day 3 Lab for using BlockingQueue solution
1 parent c05f8ae commit dca6b37

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/prodcons/ProducerConsumer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.concurrent.ArrayBlockingQueue;
55
import java.util.concurrent.BlockingQueue;
66

7+
// Trendy modern name for this (with some minor extras)
8+
// is "Actor model"
79
public class ProducerConsumer {
810
public static void main(String[] args) {
911
// need a shared BlockingQueue<int[]>
@@ -30,7 +32,7 @@ public static void main(String[] args) {
3032
if (i == 5_000) {
3133
data[0] = -1;
3234
}
33-
bq.put(data);
35+
bq.put(data); data = null; // must not touch again!!!
3436
}
3537
} catch (InterruptedException ie) {
3638
System.out.println("this shouldn't happen...");

0 commit comments

Comments
 (0)