Waiting for all threads spawned by my code under test in JUnit test case
How do I ensure in a JUnit test case, that all the the threads spawned directly/indirectly by the method under test are done with there job, so that I can assert the final result? 

@Test

public void testMethod() {

 Result result=method();// may spawn multiple threads to set result.value


 Assert.assertTrue(result.getValue()==4); //should execute only after result.value is set to its final value.

}
Waiting for all threads spawned by my code under test in JUnit test case
===

How do I ensure in a JUnit test case, that all the the threads spawned directly/indirectly by the method under test are done with there job, so that I can assert the final result? 

@Test

public void testMethod() {

 Result result=method();// may spawn multiple threads to set result.value


 Assert.assertTrue(result.getValue()==4); //should execute only after result.value is set to its final value.

}