thebuzzmedia/imgscalr — Issue #67: Potential thread locking in AsyncScalr
Author: thianpeng
Created: 2012-02-21 16:51:45+00:00
State: open

I created a Java servlet with multiple threads that are responsible to load and save data on an embedded system with only one processor and limited amount of memory. One of these threads is responsible to scale images. Currently, no other threads scales images. To experiment with AsyncScalr.resize, I set imgscalr.async.threadCount to 1 via system property. After running the servlet for a couple of days, the image scaling thread appeared to have locked indefinitely. Here is a thread dump using Java VisualVM:

"Thread-9" - Thread t@24
java.lang.Thread.State: WAITING
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <19d6984> (a java.util.concurrent.FutureTask$Sync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281)
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
...
at java.lang.Thread.run(Thread.java:662)

Locked ownable synchronizers:
- None

Please note that there is only one thread that called AsyncScalr.resize. Thank you.