make queue thread safe in push/pop operation

Two threads are touching on a same queue without a mutex in switch implementation. I observed sometimes queue length becomes negative(INTMAX), which result in infinity loop sometimes, or unexpected behaviors.