Async client blocking


I am using the async client according to the example mentioned in

I am using below get for read get(BatchPolicy policy, RecordArrayListener listener, Key[] keys)

However after making almost ~50000 requests, the threads go into a wate state. Below is the stack trace for one of the threads.

“pool-11-thread-1” - Thread t@56 java.lang.Thread.State: WAITING at sun.misc.Unsafe.park(Native Method) - parking to wait for <737890e3> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park( at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await( at java.util.concurrent.ArrayBlockingQueue.take( at com.aerospike.client.async.AsyncCluster$BlockBufferQueue.getByteBuffer( at com.aerospike.client.async.AsyncCluster.getByteBuffer( at com.aerospike.client.async.AsyncCommand.execute( at com.aerospike.client.async.AsyncMul tiExecutor.execute( at com.aerospike.client.async.AsyncBatch$GetArrayExecutor.( at com.aerospike.client.async.AsyncClient.get(

Can to tell me why this might me happening or how to prevent this


The async client can deadlock when nested async commands are issued. To fix deadlock, define a task thread pool which offloads the async callback (onSuccess()) to a thread pool which frees up the selector thread to process other commands. Here is an example:

AsyncClientPolicy policy = new AsyncClientPolicy();
policy.asyncTaskThreadPool = Executors.newCachedThreadPool(new ThreadFactory() {
	    public final Thread newThread(Runnable runnable) {
			Thread thread = new Thread(runnable);
			return thread;
AsyncClient client = new AsyncClient(policy, host, port);

See online docs at


A lock occurs when multiple processes try to access the same resource at the same time. A deadlock occurs when the waiting process is still holding on to another resource that the first needs before it can finish. A Java multithreaded program may suffer from the deadlock condition because the synchronized keyword causes the executing thread to block while waiting for the lock, or monitor , associated with the specified object. More on…Java Deadloack