Java associate object with each thread in Executor
问题 I have a bunch of runnables that I want to execute via a thread pool. However, each runnable also writes some result to some file. So right now, the runnable's interface is simple: class MyRunnable implements Runnable { ... MyRunnable(BufferedWriter writer, Task t) { this.writer = writer; this.task = t; } public void run() { ... this.writer.write(SOME_DATA); } } However, what I want is to associate one BufferedWriter (in other words, one output file) with each of the thread in the Executor