Synchronization vs Lock

If you’re simply locking an object, I’d prefer to use synchronized Example: Lock.acquire(); doSomethingNifty(); // Throws a NPE! Lock.release(); // Oh noes, we never release the lock! You have to explicitly do try{} finally{} everywhere. Whereas with synchronized, it’s super clear and impossible to get wrong: synchronized(myObject) { doSomethingNifty(); } That said, Locks may be … Read more