Use mutex instead of spinlock to fix the 16 threads issue