Skip to content
Advertisement

Tag: locking

Try-finally with lock when no exception is thrown

In the java manual it says that it is recommended to use try-finally when using lock() and unlock(), but this is also necessary when an exception is never thrown in the try block? for example: Answer Adding it always is a reasonable advice: For a beginner, because they may not be aware of all the ways exceptions might be thrown.

Execute query with MySQL GET_LOCK function in Hibernate

My application uses Hibernate as ORM. I am trying to execute few mysql locking function within my application like GET_LOCK, IS_FREE_LOCK, RELEASE_LOCK (https://dev.mysql.com/doc/refman/5.6/en/locking-functions.html). However I am running into following issue: Here is my Dao code: I am not sure how to execute locking functions using Hibernate. Any help/pointer is appreciated. Thanks in advance. Answer I found the problem. It was

Mutex Locks vs Peterson’s Algorithm?

Do mutex locks ensure bounded waiting condition ? Is it possible if two threads are trying to get hold of a lock, but only one process (just by luck) gets it again and again. Since Peterson’s Algorithm ensures bounded waiting, is it better to use that instead of mutex locks ? Answer It is possible to have unbounded wait with

Simple Java name based locks?

MySQL has a handy function: SELECT GET_LOCK(“SomeName”) This can be used to create simple, but very specific, name-based locks for an application. However, it requires a database connection. I have …

Advertisement