public static void testBarrier() throws QueueClosedException {
        RemoveOneItem[] removers=new RemoveOneItem[10];
        final Queue queue=new Queue();
        int num_dead=0;

        for(int i=0; i < removers.length; i++) {
            removers[i]=new RemoveOneItem(i, queue);
            removers[i].start();
        }

        Util.sleep(200);

        System.out.println("-- adding element 99");
        queue.add(99L);
        System.out.println("-- adding element 100");
        queue.add(100L);

        long target_time=System.currentTimeMillis() + 10000L;
        do {
            int num=0;
            for(int i=0; i < removers.length; i++) {
                if(!removers[i].isAlive())
                    num++;
            }
            if(num == 2)
                break;
            Util.sleep(500);
        }
        while(target_time > System.currentTimeMillis());


        for(int i=0; i < removers.length; i++) {
            System.out.println("remover #" + i + " is " + (removers[i].isAlive() ? "alive" : "terminated"));
            if(!removers[i].isAlive()) {
                num_dead++;
            }
        }

        assert num_dead == 2 : "num_dead was " + num_dead + ", but expected 2";
        queue.close(false);
    }