Loading…
Loading…
Java
Modern concurrency on Java 25+ — platform and virtual threads, the scheduler, structured concurrency, scoped values, reactive comparisons, and how Spring Boot, Quarkus, Micronaut, Helidon and Jakarta EE adopt them. 50 articles with practice quizzes.
How to get results and errors back from tasks run by an executor: Callable versus Runnable, Future.get with and without a timeout, ExecutionException, cancel(true), the Java 19 state/resultNow/exceptionNow methods, invokeAll, invokeAny and ExecutorCompletionService, verified on JDK 25.
kvi5hnuCode Sprout team member6 minHow ThreadPoolExecutor really decides between starting a thread, queuing a task and rejecting it. Core and maximum sizes, keep-alive, why an unbounded queue makes the maximum useless, the four rejection policies, what each Executors factory builds, and sizing rules for CPU and I/O work.
kvi5hnuCode Sprout team member8 minHow a thread pool works inside, built step by step: worker threads looping over a bounded BlockingQueue, backpressure when the queue is full, surviving failing tasks, and a correct shutdown with poison pills and join. Plus the mistakes that simple pools usually make.
kvi5hnuCode Sprout team member8 minA step-by-step plan for moving an existing Java service to virtual threads: upgrade, inspect for pinning and thread-local caches, switch executors, replace the old pool's accidental limits with explicit ones, load test and roll out. With a measured before-and-after example.
kvi5hnuCode Sprout team member9 minWhy the classic thread dump misses virtual threads, and how jcmd Thread.dump_to_file and HotSpotDiagnosticMXBean.dumpThreads capture all of them in plain text or JSON. The thread-container tree, what each entry contains on Java 25, and a program that analyzes its own JSON dump.
kvi5hnuCode Sprout team member8 minHow to observe virtual threads with JDK Flight Recorder: the jdk.VirtualThreadPinned event with its pinned reason, lifecycle and submit-failed events, recording from the command line or jcmd, reading results with jfr view and jfr print, and streaming events in-process with RecordingStream.
kvi5hnuCode Sprout team member6 minThreadLocal works on virtual threads, but per-thread caches stop paying off when every task gets a new thread. A measured comparison, InheritableThreadLocal copying and how to turn it off, finding thread-local use with jdk.traceVirtualThreadLocals, and what to use instead.
kvi5hnuCode Sprout team member7 minWhat still holds a virtual thread's carrier on current JDKs: native calls through JNI or FFM, class initialization, file I/O and long CPU-bound work (there is no time slicing). A measured one-carrier demo, the reasons, and how to offload such work to a platform pool.
kvi5hnuCode Sprout team member9 minWhat pinning is, why a pinned virtual thread blocks its carrier, and how synchronized pinned on Java 21–23 but not since JEP 491 in Java 24. A one-carrier experiment compares ReentrantLock, synchronized and class initialization, with advice for each Java version.
kvi5hnuCode Sprout team member8 minVirtual threads remove the thread pool's built-in cap, so scarce resources need explicit protection. How to use java.util.concurrent.Semaphore as a bulkhead, with timeouts, fairness and the release-only-if-acquired rule, and how a concurrency limit differs from a requests-per-second rate limit.
kvi5hnuCode Sprout team member8 minWhat really happens when a Java virtual thread blocks: stack frames frozen into heap objects, the carrier freed, the poller or timer waiting for the event, and frames thawed onto any carrier when the thread resumes. Which JDK operations unmount, and why the carrier stays invisible.
kvi5hnuCode Sprout team member8 minWhy virtual threads raise throughput without making anything faster. Little's Law (N = λ × d) explained with a measured comparison of fixed thread pools and virtual threads, how to size pools for blocking work, and the workloads where virtual threads help or don't.
kvi5hnuCode Sprout team member9 minEvery way to create and run Java virtual threads: Thread.startVirtualThread, Thread.ofVirtual builders, ThreadFactory, newVirtualThreadPerTaskExecutor and newThreadPerTaskExecutor. Plus interruption, cheap blocking Future.get, invokeAll, and setting up a JDK for virtual threads.
kvi5hnuCode Sprout team member7 minThe two kinds of Java threads explained: OS-backed platform threads and JVM-scheduled virtual threads. How carriers and the ForkJoinPool scheduler work, which Thread properties are fixed for virtual threads, what a virtual thread costs, and how to tune the scheduler.
kvi5hnuCode Sprout team member8 minWhat reactive frameworks such as Reactor and Spring WebFlux solve, what they cost in learning, debugging and lock-in, and how virtual threads offer the same scalability for blocking code. Includes a Reactor version of a request and 10,000 concurrent requests on virtual threads.
kvi5hnuCode Sprout team member10 minHow ForkJoinPool's per-worker deques and work stealing keep cores busy and caches warm, and how CompletableFuture turns a request's blocking calls into a non-blocking dependency graph with timeouts and fallbacks. Plus the real costs: harder debugging, lost cancellation and a steep learning curve.
kvi5hnuCode Sprout team member9 minRewriting a parallel fan-out with ExecutorService and Future: bounded, reused threads and errors that reach the caller. Then the limits that remain: Future.get still blocks, shared queues and cache-line false sharing cost performance, and futures don't compose.
kvi5hnuCode Sprout team member9 minWhy a request that makes several blocking calls is slow, how running independent calls on separate threads cuts its latency, how to pass results back safely with join and AtomicReference, and the failures, leaks and missing cancellation that make hand-made threads a poor long-term answer.
kvi5hnuCode Sprout team member8 minWhy the thread-per-request model hits a wall with platform threads: stack memory per thread, OS thread limits, context-switch overhead, and what throughput really measures. Includes a measured experiment and how to find your own machine's limits.
kvi5hnuCode Sprout team member9 minEvery way to create a Java thread, from extending Thread and implementing Runnable to lambdas and the Java 21 Thread.Builder. Why start() differs from run(), why executors replaced hand-made threads, and how to handle InterruptedException correctly.
kvi5hnuCode Sprout team member8 min