Perform the following steps to implement the example:
- Create a class named Producer and specify that it implements the Runnable interface:
public class Producer implements Runnable {
- Declare a private LinkedTransferQueue attribute parameterized with the String class named buffer:
private LinkedTransferQueue<String> buffer;
- Declare a private String attribute named name to store the name of the producer:
private String name;
- Implement the constructor of the class to initialize its attributes:
public Producer(String name, LinkedTransferQueue<String> buffer){ this.name=name; this.buffer=buffer; }
- Implement the run() method. Store 10,000 strings in the buffer using the put() method of the buffer object and write ...