Skip to content

Tag: locking

Locking execution within CompletableFuture

I need to post-process result of CompletableFuture.supplyAsync execution to get intermediate result. My code looks following In a result I’m facing with java.util.concurrent.CompletionException: java.lang.IllegalMonitorStateException on .thenAccept(resultPerBatch -> { line Seems like I’m using …

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 excepti…

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…