using condition in synchronized code