Code example for ArrayBlockingQueue

public class labelPrinter { 
	private static String url = "http://admin.touchofmodern.local:3000/shipments/scan_label";
	public static void main(String[] args) throws Exception{
		BlockingQueue<Post> queue = new ArrayBlockingQueue<>(20);
		PostGenerator generator = new PostGenerator(queue);
		Printer printer = new Printer(queue);
		//Start generator to produce jobs in the queue 
		new Thread(generator).start();
		//Start printer to consume jobs 
		new Thread(printer).start();
		System.out.println("Both threads started");
Experience pair programming with AI  Get Codota for Java