Tagged “Java”
14 articles with this tag.
- Concurrency design patternsHow to introduce threads into an application: oneway messages, thread-per-message, worker threads and pools, completion callbacks, futures and joins, cooperative cancellation, push-flow pipelines, parallel decomposition with fork/join and barriers, and readers-writers — mapped from Doug Lea's patterns to modern Java 21 APIs.
- Designing concurrent objectsDoug Lea's design forces for concurrent Java — safety, liveness, performance and reusability — and the strategies for thread-safe objects: immutability, confinement, full synchronization, containment, lock splitting, optimistic updates with CAS, deadlock avoidance through lock ordering, and documenting thread-safety policies.
- Exceptions & try-with-resourcesDesigning and handling exceptions in Java: the Throwable hierarchy, checked vs unchecked, try-catch-finally semantics, try-with-resources and suppressed exceptions, exception translation and chaining, custom exceptions, exceptions in lambdas and CompletableFuture, logging, and API design guidelines.
- Lambdas & StreamsFunctional Java explained: functional interfaces and the java.util.function catalogue, lambdas and capture rules, the four kinds of method references, the Streams API pipeline (lazy evaluation, intermediate and terminal operations), collectors, primitive streams, parallel streams, stream gatherers (Java 24), Optional done right, and performance pitfalls.
- Garbage collectionHow the JVM reclaims memory: reachability and GC roots, the generational hypothesis, mark-sweep-compact, Serial, Parallel, G1, generational ZGC and Shenandoah compared, pause vs throughput trade-offs, heap sizing in containers, reading GC logs, memory leaks, and recent changes through Java 27.
- Generics & type erasureHow Java generics give compile-time type safety: type parameters, bounded types, generic methods, wildcards and PECS, type erasure and bridge methods, what you cannot do at runtime, heap pollution, and practical API design rules.
- Records, sealed & patternsData-oriented programming in modern Java: records, sealed classes and interfaces, pattern matching for instanceof and switch, record patterns, exhaustiveness, unnamed variables, text blocks and var, plus what Java 22–27 added (flexible constructor bodies, module imports, compact source files, primitive patterns in preview).
- Reflection & dynamic proxiesHow Java inspects and changes behaviour at runtime: Class objects, fields, methods, constructors and annotations via reflection, MethodHandles, JDK dynamic proxies vs CGLIB and ByteBuddy, how frameworks like Spring and Hibernate use them, performance, module encapsulation and GraalVM native-image constraints.
- State-dependent actionsWhat a concurrent object should do when a request arrives in the wrong state: balk, wait (guarded suspension), wait with a timeout, or retry. wait/notify done correctly, Condition objects, a bounded buffer, interruption, the inheritance anomaly, and when to use BlockingQueue and other synchronizers instead.
- Collections FrameworkHow Java collections work inside: the interface hierarchy and sequenced collections (Java 21), ArrayList vs LinkedList, HashMap internals (hashing, buckets, treeification, resizing), LinkedHashMap and LRU caches, TreeMap, sets, queues and deques, immutable collections, fail-fast iterators, and choosing the right collection.
- Concurrency APIPractical java.util.concurrent: threads vs tasks, ExecutorService and thread-pool sizing, Future and CompletableFuture composition and error handling, locks (synchronized, ReentrantLock, ReadWriteLock, StampedLock), atomics and LongAdder, synchronizers, concurrent collections and BlockingQueue, and how they relate to virtual threads.
- Java Memory ModelWhy concurrent Java code can see stale or reordered values: CPU caches and reordering, the Java Memory Model, happens-before rules, volatile, synchronized and final semantics, safe publication, double-checked locking, data races vs race conditions, and the JVM runtime memory areas (heap, stack, metaspace).
- Module system (JPMS)Java modules explained: module-info.java, requires, exports, opens and uses/provides, strong encapsulation, the module path vs classpath, automatic and unnamed modules, services, jlink custom runtimes, module import declarations (Java 25), how Spring and frameworks cope, and when modules are worth it.
- Virtual threadsJava's lightweight concurrency model: how virtual threads work (mounting, carriers, continuations), when they help, pinning and the Java 24 fix, using them in Spring Boot, structured concurrency for fan-out, scoped values vs ThreadLocal, and comparison with reactive programming.