I believe you forgot to add a semaphore wait/signal in this method. There might be other ones, I didn't look closely.