java
6 minJava deadlines: spend one budget across every stage
Separate elapsed time from civil time and carry a shrinking deadline through a request.
Loading page...
java
6 minSeparate elapsed time from civil time and carry a shrinking deadline through a request.
java
9 minDiagnose collection bugs caused by inconsistent equality, mutable keys, inheritance, and accidental identity comparisons.
Q&A
Q&AFresh timeouts at each stage multiply the total wait.
Measure elapsed time locally with nanoTime and give each stage only the shared budget remaining. Expiry stops admission of more work; it does not prove a remote write was cancelled.
Q&A
Q&AIt must own the monitor, releases that monitor, and waits until notified or interrupted.
Object.wait() requires ownership of that object’s monitor. The thread releases that monitor and enters a waiting state until notification, interruption, timeout, or spurious wakeup; it must reacquire the monitor before returning. Always wait in a while loop that rechecks the condition, and use higher-level concurrency utilities where possible.
Q&A
Q&AA live root still reaches an object, class, or thread state owned by the old loader.
Look for parent-owned registries, executor queues, thread locals, context class loaders, and callbacks. An unreachable cycle can be collected; a path from a long-lived root cannot.
Q&A
Q&AFind a cycle in lock ownership and waiting, then remove inconsistent nested lock ordering.
Capture repeated thread dumps with jcmd or jstack while the incident is active. A deadlock cycle shows threads waiting for locks held by each other; distinguish it from starvation or a slow dependency by checking whether owners can progress. Fix consistent lock order, shorten critical sections, or redesign ownership so both locks are not required together.
Q&A
Q&AUse repeated thread dumps and lock profiling to locate hot locks, then reduce serialization safely.
Capture repeated thread dumps and identify many threads blocked on the same owner or monitor. Use a profiler or JFR lock events to quantify contention and critical-section time. Reduce lock scope, shard independent state, batch updates, or use concurrent primitives only when they preserve the invariant; verify throughput and correctness under representative load.
java
5 minTurn a local appointment into an instant without silently shifting nonexistent times or choosing an ambiguous offset.