Functional programming, by its nature, is thread safe; immutability has a great role in making it thread safe. If you go by the dictionary definition, immutability means that something is unchangeable. So, as per the dictionary, an immutable variable is a variable that cannot change. Now, how can that be of any help to thread safety?
The following example shows a simple class, with no extra protective measures for thread safety:
class MutableObject { var mutableProperty:Int = 1 }
Just think of a situation when you're calling this class from multiple threads at the same time. There is no guarantee of integrity in this, right?
Now, imagine making mutableProperty immutable; the problem is partly solved, right?
However, if you think of immutability as creating a class and making all its variables read-only, then such a simplified explanation would...