MultiThread Race Condition

I am creating an application that is multithreaded and all the threads are accessing the same shared memory. The data coming into the memory should be processed in sequential order. Like if 1,2,3,4,5 comes in the memory then it should be processed in same order.

I have used critical section around my memory, but I still get into a race condition where data is not grabbed by the thread in sequential order.

Am I missing anything else to prevent threads from race condition?