# How to put Aerospike Async Client into wait till all submitted job completed?

**URL:** <https://discuss.aerospike.com/t/how-to-put-aerospike-async-client-into-wait-till-all-submitted-job-completed/2758>\
**Category:** Java Client\
**Tags:** udf\
**Created:** [March 31, 2016, 1:02pm UTC](https://discuss.aerospike.com/t/how-to-put-aerospike-async-client-into-wait-till-all-submitted-job-completed/2758 "2016-03-31T13:02:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineet\_singh](https://avatars.discourse-cdn.com/v4/letter/v/4491bb/32.png) [@vineet\_singh](https://discuss.aerospike.com/u/vineet_singh)\
**Post date:** [March 31, 2016, 1:02pm UTC](https://discuss.aerospike.com/t/how-to-put-aerospike-async-client-into-wait-till-all-submitted-job-completed/2758/1 "2016-03-31T13:02:12Z")

</div>

I am inserting 10 million record using Aerospike Async client in loop and after finishing loop i am calling if(aerospikeClient != null && aerospikeClient.isConnected()) aerospikeClient.close(); But then i am start getting **"com.aerospike.client.AerospikeException: java.util.concurrent.RejectedExecutionException:**". That means job is still running when aerospikeClient close connection.

Is there any way we can put wait till all submitted job completed. I can do this using some atomic global variable but i want to know whether this feature is present in java client library

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [April 8, 2016, 12:33am UTC](https://discuss.aerospike.com/t/how-to-put-aerospike-async-client-into-wait-till-all-submitted-job-completed/2758/2 "2016-04-08T00:33:17Z")

</div>

There is no current mechanism to wait until all async commands have finished.
