Possible Duplicate:
Is mutex needed to synchronize a simple flag between pthreads?
In a POSIX environment I have two threads (initialized with pthread_create()
), A and B.
A is sometimes writing into a flag variable (an int
) and B is sometimes reading it.
Do I need to protect this variable with a mutex or can those operations always be considered as atomic?