+ private static final List<Callback> callbacks = new ArrayList<>();
+
+ public static Transliterator get(String rules) {
+ // DO NOT make the method synchronized!
+ // synchronizing on the class would break the whole
+ // asynchronous init concept, since the runnable
+ // then holds the same lock as the init function needs.
+ Transliterator result;
+ synchronized (cache) {
+ result = cache.get(rules);
+ if (result == null) {
+ result = Transliterator.createFromRules("", rules, Transliterator.FORWARD);
+ cache.put(rules, result);
+ }
+ }
+ return result;
+ }