I have many threads that writes to a pool of files, I want to synchronize filewriter to avoid a dirty append.
Firstly I thought about this:
public synchronized void write(Ing ing) {
File file=getFile(ing);
FileWriter writer;
writer=new FileWriter(file,true);
// ...
}
but this synchronizes all writes, and I want to synchronize only writes on THE SAME file.