Link to home
Start Free TrialLog in
Avatar of amhicraig
amhicraigFlag for United States of America

asked on

file writing to disc in a multiuser enviornment.

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.
Avatar of araim
araim
Flag of Poland image

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)

ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial