I have a multithreaded app, where i spawn n threads, i need to execute a method before these threads run,
and also after all of these n threads have finished running. How do I achieve it, via Thread-Group or any java1.5 compatible API.
You can use a CyclicBarrier with a barrier action that execute the method call when the last thread enters it.
However the requirement of the initial method call is unclear to me. Can't you simply execute that method before spawning the threads?
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Joined: Apr 10, 2012
Hey Jelle Klap, Many thanks for your reply, You are right, the 1st part i have called before swapping the threads,
the only issue now left is the later part. Can i achieve the same via ThreadGroup.