Does a thread waiting on IO also block a core?

A CPU core is normally not dedicated to one particular thread of execution. The kernel is constantly switching processes being executed in and out of the CPU. The process currently being executed by the CPU is in the “running” state. The list of processes waiting for their turn are in a “ready” state. The kernel … Read more

Wrapping an asynchronous computation into a synchronous (blocking) computation

Using your own Future implemenation: public class BazComputationFuture implements Future<Baz>, BazComputationSink { private volatile Baz result = null; private volatile boolean cancelled = false; private final CountDownLatch countDownLatch; public BazComputationFuture() { countDownLatch = new CountDownLatch(1); } @Override public boolean cancel(final boolean mayInterruptIfRunning) { if (isDone()) { return false; } else { countDownLatch.countDown(); cancelled = true; … Read more

tech