lock gives an exception in emulator