Re: How to lock a file and detect a thread is over?# Java - 爪哇娇娃
E*l
1 楼
Usually what you should do for situation like this is to
design a class with mutually exclusive functions (use
synchronized prefix). All the file access should be implemented
in this class. In this way when a thread is doing something
to the file, no other thread can access the file. This may
not be what you want if you want to allow multiple threads
to read the file at the same time though. You can follow
the logic and design a class which allows multiple reads but
no read when writing is goin