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;
}
@Override
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) {
break;
//this gets tripped when you shut the ExecutorServiceDown…the loop ends
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
}
executorService.shutdownNow();
executorService.submit(new VisionQueueReader(visionMessageQueue));

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why you should be using fzf, the command line fuzzy finder

Introduction to Functional Programming in F#

The 10 Commandments Of Software Development

Dynamics 365 and creating reporting databases

Applying the single responsibility principle to microservices

Monolith to Microservices — Migration patters

Connect to Github via SSH in CentOS

5 things to know before you start learning Webflow

webflow university

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

More from Medium

The Compression Chronicles: Huffman Encoding

Shortest Unsorted Continuous Subarray solution

Number of Paths — Pramp question Java

Merge or Split PowerPoint Presentations in Java