On the ThreadPoolExecutor docs, (here), it says to use the Executors class to create common threads, I want to only have one thread, so I use Executors.newSingleThreadExecutor and cast it to ThreadPoolExecutor as I have seen other examples do, but this throws a java.lang.ClassCastException.
Here is the minimalised code I have reproduced it with.
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
public class Test {
public static void main(String[] args) {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newSingleThreadExecutor();
}
}