Which statements are true about the following code?
public class Main { private int alt; public synchronized void up() { ++alt;/* w w w. j av a 2 s.c o m*/ } public void down() { --alt; } public synchronized void jump() { int a = alt; up(); down(); assert(a == alt); } }
Select the two correct answers.
up()
method concurrently.down()
method concurrently.up()
and the down()
methods concurrently.jump()
method will not fail under any circumstances.(c) and (d)
Executing synchronized code does not guard against executing non-synchronized code concurrently.