Hello ,
In my doPost method of the servlet I need to access a file (shared resource ) and update the file . How do I cater to some 100 users using this at the same time ?
Regards, Mithun
Hello ,
In my doPost method of the servlet I need to access a file (shared resource ) and update the file . How do I cater to some 100 users using this at the same time ?
Regards, Mithun
Are you sure a file is how you want to handle this? Protecting access to data by multiple concurrent users is most of what a modern database does.
With high level of concurrency (for writes), synchronizing will cost you a lot of throughput.
Databases are more adequate to handle this, if possible in your project.
I would take advantage of the java.util.concurrent packages added in Java 1.5. Specifically a BlockingQueue to queue up requests and handle them in a second pool of threads.