You can use a single-threaded executor to write a file for each event.
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(new Runnable() {
public void run()
{
}
});
There will be only one thread, and the performer will take care of the queue.
source
share