Code example for CountDownLatch

Methods: getCount

0
    @Test 
    public void testNestedEvents() 
    { 
        bus.register( this );
        bus.post( new FirstEvent() );
        Assert.assertEquals( 0, latch.getCount() );
    } 
 
    @EventHandler 
    public void firstListener(FirstEvent event)
    { 
        bus.post( new SecondEvent() );
        Assert.assertEquals( 1, latch.getCount() );
        latch.countDown();
    } 
 
    @EventHandler 
    public void secondListener(SecondEvent event)
    { 
        latch.countDown();
    }