In the majority of cases, it works thread-safefly, but let's suppose as below.

1. Thread A is running "ConcurrentBatchQueue.TryEnqueue" method, and current running point is just before the "int oldCount = Interlocked.CompareExchange(ref entity.Count, expectedCount, count)"

2. Thread B is running ConcurentBatchQueue.TryDequeue method, and current running point is just after the "Interlocked.Exchange(ref m_Entity, m_BackEntity)"

Under this situation, let's suppose that only "Thread B" is currently focused by CPU, so it start to proceed, and the current running point of "Thread B" became "m_BackEntity = entity", and then, "Thread A" is suddenly
focused by CPU and suppose that it start to run.

In this case, the dequeue process is already finished, but "Thread A" is try to enqueue data, but the enqueing point of "Thread A" will be invalid point, isn't it ?