The best tool for "do exactly once" types of tasks that I've found is
AtomicBoolean:
| private final AtmoicBoolean freed = new AtomicBoolean(false);
|
| // ...then later, in your idempotent free() method:
| if (! freed.getAndSet(true)) {
| doTheOneTimeTask();
| }
|
Of course that's JDK5+ only, so it might not be suitable for things that have to run
on older JDKs.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166529#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...