Use Multiple threads for 'WSTm' methods like 'insert' or 'searchFreeform'

I am creating a servlet to update TM but adding the TM sequentially is taking more time than expected.

I tried to create ExecutorService which is creating multiple threads and running them parallel to call the update the api with some strings

The code goes something like - 


ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
List<CompletableFuture<Void>> futures = strs.stream().map(mapContent -> CompletableFuture.runAsync(() -> updateTMCall(mapContent, contentType, TmToUpdate, sourceLanguage, targetLanguage), executorService))
.collect(Collectors.toList());
futures.forEach(CompletableFuture::join);

The error i am facing is this one - (covers java.lang.RuntimeException: java.util.concurrent.CompletionException: com.idiominc.ws.storage.StorageException (covers com.idiominc.ws.sql.ConnectionLeaseStateException: ConnectionLease not returned) on line where i am using TmToUpdate.searchFreeform() or TmToUpdate insert() method.

World Server - Version 11.7.3.328

Please let me know how can this be achieved.
Thank You.

emoji