File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Threads and Synchronization
Appending contents to one file from multiple threads
Joined: Jun 28, 2009
Mar 28, 2013 21:59:22
I have a web application and all the requests and threads are writing to a single file. What is the best way to handle this. As far my understanding goes, the potential issues could be corruption of data ...
Joined: Jan 03, 2004
Mar 29, 2013 10:10:56
The simplest and safest approach would probably be to use a producer/consumer model where N threads insert their requests into a queue and 1 thread reads from that queue and writes to the file. If you use
, you wouldn't even have to handle the synchronization yourself.
I agree. Here's the link:
subject: Appending contents to one file from multiple threads
ImageIO performance is very low in solaris compared to windows need an alternative
Creating a file by giving relative path
WA #1.....word association
Struts FormFile (parsing .csv files)
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014