|
From: Bruce M. <br...@mc...> - 2003-04-17 01:42:06
|
Looks good - thanks for the work Eric - resource contention and running down
race conditions can be thankless work, so I thank you right here. This is
the kind of thing that needs to be done.
On Wednesday 16 April 2003 07:05 pm, ek...@ba... wrote:
> I am proposing adding synchronized blocks to certain methods in this class
> to prevent multithreading problems from occurring when reading and writing
> configuration information to and from the cache.
>
> Lines preceded by ** are modified or added.
>
> Here are the proposals:
>
> public IConfig getConfig(String name, Locale locale) {
> String key = name + locale.toString();
> IConfig config = (IConfig) configs.get(key);
> if (config == null) {
> ** synchronized {
> config = configService.getConfig(name, locale);
> configs.put(key, config);
> ** }
> }
>
> return config;
> }
>
> Same modification in public IConfig getConfig(String name).
>
>
> Additionally, the following changes would be made to saveConfig to keep
> the same information from being written by two different threads (with
> potentially different data) and to clear the Cache when the save is
> complete:
>
> ** public synchronized boolean saveConfig(String name, IConfig config) {
> //System.out.println("Getting config: "+name);
> if (config != null) {
> //System.out.println("Config: "+name+" not found, loading.");
> ** boolean saved = configService.saveConfig(name, config);
> ** if (saved) {
> ** clearCache();
> ** }
> ** return saved;
> } else {
> return false;
> }
> }
>
>
> Please let me know if you approve of this.
>
> ________________________________________________________________________
> The information in this e-mail, and any attachment therein, is confidential
> and for use by the addressee only. If you are not the intended recipient,
> please return the e-mail to the sender and delete it from your computer.
> Although The Bank of New York attempts to sweep e-mail and attachments for
> viruses, it does not guarantee that either are virus-free and accepts no
> liability for any damage sustained as a result of viruses.
|