Replace semaphore with wait()/notify() to prevent reaching code before filter was destroyed (destroying the filter and particularly its buffer later results in NPE)