What is non-thread-safety for?-Collection of common programming errors

So, what is the point of keeping non thread-safe code?

By allowing for code that isn’t thread safe you’re leaving it up to the programmer to decide what the correct level of isolation is.

As others have mentioned this allows for complexity reduction and improved performance.

Rico Mariani wrote two articles entitled “Putting your synchronization at the correct level” and Putting your synchronization at the correct level — solution that have a nice example of this in action.

In the article he has a method called DoWork(). In it he calls another classes Read 2x Write 2x and then LogToSteam.

Read, Write, and LogToSteam all shared lock a lock and where thread safe. Except of course because DoWork was also thread safe. This meant all the synchronizing work in each Read, Write and LogToSteam was a complete waste of time.

This is all due to the nature Imperative Programming. It side effects cause this.

However if you had an development platform where applications could be expressed as pure functions where there were no dependencies or side effects then it would be possible to create applications where the threading was managed without developer intervention.