Attempt to tackle an Android deadlock

Use dedicated lock objects instead of locking on the class object
See #196