about atomicExch

i have met a problem, many threads may write the same memory, but when i use atomicExch, the result seemed to be not right.
how to solve this,

You have to explain what “not right” means and post your code. Atomic functions are tricky, make sure you read the documentation (CudaReferenceManual.pdf) carefully. (Also, what GPU are you using?)