We help IT Professionals succeed at work.

file writing to disc in a multiuser enviornment.

amhicraig
amhicraig asked
on
168 Views
Last Modified: 2013-11-23
I have to generate a file x through a method.Based on the data input to the method the files contents will vary.How will i do this if there are 100 users all using the system at the same time - in such a scenario when user a is viewing the file the file will be modified by user b which is not desirable.Pl. advise.
Comment
Watch Question

Commented:
use some form of synchronization
either synchronized keyword
for example
Class x{
File f = new File(...);
....
}
synchronized(f){
 // read , write .. do stuff - single user, single thread
}

or use java.util.concurrent  (for example single Semaphore)

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.