[jboss-dev-forums] [Design of JCA on JBoss] - Re: [JBAS-5095] Race condition between connection.close() an

david.lloyd@jboss.com do-not-reply at jboss.com
Thu Jul 24 19:06:53 EDT 2008


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#4166529

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166529



More information about the jboss-dev-forums mailing list