synchronize on this in the override, ......
uh, how many places in the code would have to be re-designed to take the override you already wrote?.. dozens, hundreds?.. that's not workable.
By re-design the File override, all that need be done is place one synchronized(this) on entry, the real trick is going past contemporary design practice of synchronizing on a Lock Object, thus:
|
Code:
|
class FileClass{ private Object Lock;
public get(){....
public set(){.... |
the fix, though not generally recognized in contemprary literature, is to do get(boolean set, retrieve, some action, which design leads to other issues., notably in that having one call signature for read and write, the method must return a data object, that makes confirming the boolean sucess of the call dicey at best.
It's a battle, I recognize this. I was up a 4am this morning fixing that in my own code.
The central office called just now, they want to know where everything is.
To shorten it up, place *all* calls to file on one call to new - somewhere early in program init(); Propogate the object either in constructors or in a get call for the file object that returns this. Then put a synchronized(this) at an outer scope in the file object. To do otherwise will have the Office Above giving Hell from Above.
See Servlet design, that is a good design. It addresses the issue well if one reads up on how to do that correctly on demand load,... some sort of feed-forward design.