I have a class offering translation utilities. The translations themselves need to be reloaded every 30 minutes. I use Spring timer support. Basically, my class is as follows:
public interface Translator {
public void loadTranslations();
public String getTranslation(String key);
}
loadTranslations () can be quite long to run, so while it works, old translations are still available. This is done by downloading translations on a local map and simply changing the link when downloading all translations.
My problem: how can I make sure that when the thread is already downloading translations, the second one tries to start, it detects this and immediately returns without launching the second update.
The synchronized method will only queue the loads ... I'm still in Java 1.4, so there is no java.util.concurrent.
Thank you for your help!
source
share