|
From: Dejan K. <dej...@nb...> - 2003-04-17 06:05:43
|
Agreed. I noticed certain problems when running multiple threads (scanners)
at the same time. I guess there are other bugs too but several times my
scanner theads were in deadlock while doing initalization (reading
configuration)...
Dejan
----- Original Message -----
From: ek...@ba...
To: bab...@li...
Sent: Thursday, April 17, 2003 1:05 AM
Subject: [Babeldoc-devel] Synchronizing methods in
com.babeldoc.core.config.ConfigService
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.
|