Are these advanced/unfair interview questions regarding Java concurrency?
Posted
by
sparc_spread
on Programmers
See other posts from Programmers
or by sparc_spread
Published on 2012-12-07T23:37:58Z
Indexed on
2012/12/07
23:43 UTC
Read the original article
Hit count: 253
Here are some questions I've recently asked interviewees who say they know Java concurrency:
- Explain the hazard of "memory visibility" - the way the JVM can reorder certain operations on variables that are unprotected by a monitor and not declared
volatile
, such that one thread may not see the changes made by another thread. Usually I ask this one by showing code where this hazard is present (e.g. theNoVisibility
example in Listing 3.1 from "Java Concurrency in Practice" by Goetz et al) and asking what is wrong. - Explain how
volatile
affects not just the actual variable declaredvolatile
, but also any changes to variables made by a thread before it changes thevolatile
variable. - Why might you use
volatile
instead ofsynchronized
? - Implement a condition variable with
wait()
andnotifyAll()
. Explain why you should usenotifyAll()
. Explain why the condition variable should be tested with awhile
loop.
My question is - are these appropriate or too advanced to ask someone who says they know Java concurrency?
And while we're at it, do you think that someone working in Java concurrency should be expected to have an above-average knowledge of Java garbage collection?
© Programmers or respective owner