ichfarbstift ichfarbstift - 6 months ago 97
Java Question

sun.misc.Unsafe.park triggered by JDBC calls

In our application we have seen threads spending a lot of time locked via a call to the

method. We have noticed that this pattern typically is triggered by JDBC calls to the database.

I do not know much about the
method. I am wondering whether this is normal behavior indicating that the thread is waiting for input from the DB, or if there is some synchronization issue with our application that we could improve.

Do you know which of the two it is? Alternatively, do you know ways in which we could investigate the matter further?


sun.misc.Unsafe.park is pretty much the same as thread.wait, but it uses architecture dependent code, due to the fact that park is native call, it can get the benefit in performance (it's a popular pattern in java.util.concurrent, e.g. you can see the usage of park in ConcurrentLinkedQueue and thread pooloing). Obviously that you have a multithread environment and db connections use thread pool for own purposes. In the jdk parking brings significant optimization.

About your situation with JDBC, I would suggest a deadlock is going on in your case. All threads are waiting for some event. You can investigate a deadlock, I would like to advise you to read this articles:


jdbc and deadlocks manual