Untangling a String with a Thread (see what I did there…?)

private ExecutorService executorService = Executors.newFixedThreadPool(1);
private ArrayBlockingQueue visionReaderQueue= new ArrayBlockingQueue(1000,true);
import java.util.concurrent.ArrayBlockingQueue;

public class VisionQueueReader implements Runnable {
private ArrayBlockingQueue queue;
public VisionQueueReader(ArrayBlockingQueue queue) {
this.queue = queue;
public void run() {
while (!Thread.interrupted()) {
try {
String messageFromQueue = queue.take();
//Here is where you do whatever processing on the json you need to…chance are this class might also have a Static reference to the Subsystem waiting for the message
} catch (InterruptedException e) {
//this gets tripped when you shut the ExecutorServiceDown…the loop ends
} catch (NumberFormatException e) {
executorService.submit(new VisionQueueReader(visionMessageQueue));



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jamie McIlroy

Jamie McIlroy

Husband and Father. Wilderness First-Aid Certified. Terrible at tying knots. I play Squash. I like things that Trade. Leafs fan. FRC and Scouts Canada