This example shows how to use the async methods of Twitter4j to make requests to the Twitter API, but it only makes one request.
I want to be able to fire multiple queries to the API, execute them asynchronously and wait for them to finish before exiting the program.
Since I'm not creating the threads myself, I'm not sure how I can create the synchronization mechanism. I thought about creating some kind of thread counter, and decrementing it on the callback listeners, but seemed a little hackish.
Any help? Thanks.
this might be what you are looking for https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CountDownLatch.html