optimize fifo for multiple threads condition