D
Donkey Hot
(e-mail address removed) wrote in (e-mail address removed):
If playing with threads, why don't you just write one more thread, which is
the one writing to the destination file. All other threads sent the data to
it, which has a buffer (list maybe) for the data to write.
No locks, one writer.
Hi All,
I am writing a program that opens a huge flat file, process it and
write it to another file. Just in case that I get to any performance
issue, I am considering implement it in multi-threading fashion.
I remember from old days that I need to write a factory, distributer,
filewriter class, locking/unlocking routine in order to achieve it.
Someone told me instead of all those, use non-blocking IO (NIO) and
ask all threads to write to a single file without thinking about
locking/semaphore.
Is it true? If yes, anybody has a sample code for it? Is it easier
than writing it the way I've described?
If no, anybody have a sample of code do such a thing?
Thanks in advance,
Homer
If playing with threads, why don't you just write one more thread, which is
the one writing to the destination file. All other threads sent the data to
it, which has a buffer (list maybe) for the data to write.
No locks, one writer.