Anyone knows a class that would act like a VariableCountDown? i.e. you have countUp and
countDown?
I need to find an elegant way to implement this:
Say, you have messages being added to a transaction. Of course you will never know of hand
how many messages are added to the transaction until you have called commit.
When the commit is called you need to wait the callback for every message being persisted
before leaving the method, so at that point I would call await for every message that was
added to the Latch.
Semaphores won't work as we don't know the number of requests of hand. So I looked
into AbstractQueuedSycnrhonizer.. but the implementation is so trivial that I ended up
copying CountDownLatch as VariableCountLatch. The result worked the way I expected, but I
don't want to reinvent the wheel if there is some class out there doing what I needed.
(Of course I googled it.. but I didn't find anything like that)
I could just write a wait/notify object over simple synchronization, but I was looking for
a java.util.concurrent style of implementation for this. But if we find out there is no
good reason for it I can just implement the synchronize, counter--, counter++, wait and
notify approach. (i.e. the traditional way)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148952#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...