I want to write a code where all threads append values at the end of an array.
But the problem i am facing is of synchronisation.
Few threads are overwriting at the same index.
Can anybody suggest me some way by which i can append values in an array without overwriting at same index ?
My code is:
count=0; int index=atomicAdd(count,1); array[index]=some value; //I want this instruction to be atomic.