Follow the steps described next to implement the example:
- Create a class named Client and specify that it implements the Runnable interface:
public class Client implements Runnable{
- Declare a private LinkedBlockingDeque attribute parameterized by the String class named requestList:
private final LinkedBlockingDeque<String> requestList;
- Implement the constructor of the class to initialize its attributes:
public Client (LinkedBlockingDeque<String> requestList) { this.requestList=requestList; }
- Implement the run() method. Insert five String objects into the deque per second using the put() method of the requestList object. Repeat this cycle three times:
@Override public void run() { for (int i=0; i<3; i++) ...