Files

17 lines
877 B
Plaintext

== Q13: volatile is visibility, not atomicity ==
volatile int, 8 threads x 100000 increments: LOST UPDATES (expected 800000)
AtomicInteger, same work: 800000
== Q14: exceptions inside an ExecutorService ==
after submit(): no output yet, future.isDone() = true
future.get() -> ExecutionException, cause = java.lang.IllegalStateException: boom from submit
uncaught handler on worker: boom from execute
== Q15: ConcurrentHashMap is safe per call, not per sequence ==
containsKey/put/get sequence: LOST UPDATES (expected 80000)
merge(key, 1, Integer::sum): 80000
== Q16: ReentrantLock.tryLock with a timeout ==
tryLock(50 ms) while another thread holds it -> false
tryLock() after the holder released it -> true
== Q17: 10,000 blocking tasks on virtual threads ==
tasks completed = 10000, ran on virtual threads = 10000
finished in under 5 seconds: true