Properly fix #41. Simply adding a non-atomic boolean check doesn't actually resolve that issue, just made it less likely to happen. This patch makes the client use proper Java Lock objects to maintain synchronicity