Question

Can an Executor run multiple tasks on a single thread?

Obviously the task execution cannot happen simultaneously with only one physical core to run on, but is there a way to wait or yield so the other submitted tasks can run?

If there is not a wait then how else can one determine, generally, when the other task will run?

Was it helpful?

Solution

Yes.

Not with the current implementations.

No.

;)

Consider the documentation on SingleThreadExecutor (http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Executors.html#newSingleThreadExecutor()), and Wait between tasks with SingleThreadExecutor on StackOverflow.

You could implement your own thread-sharing lock between threads, and run them on a multi-thread executor... but if you want someone else's implementation to do that, well, as far as I know, you're out of luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top