What is the difference between streaming and thread safe?

What is the difference between thread awareness and thread safety?

+7
source share
2 answers

courtesy of http://sreekalyan.blogspot.com/2007/01/thread-safe-and-thread-aware.html

Thread Aware At any given time, no more than one thread can be active on an object. An object knows about the threads around it and protects itself from threads by placing all threads in a queue. Since at the moment there can be only one stream on the object, the object always maintains its state. There will be no synchronization problems.

Safe thread: At the moment, several threads can be involved in the facility. The object knows how to deal with them. It has correctly synchronized access to its shared resources. It can store its state data in this multi-threaded environment (i.e., it will not fall into intermediate and / or undefined states). It is safe to use this object in a multi-threaded environment.

Using an object that is neither streaming or thread safe can result in incorrect and random data and mysterious exceptions (due to an attempt to access the object when it is used by a stream and is in an unstable state, in - between the state at the moment of access of the second flow).

+6
source

I would believe that a function that performs its own mutex lock serialization is thread safe, but maybe not aware of the thread.

+1
source

All Articles