I have a code in scala that, for various reasons, have few lines of code that cannot be accessed by more threads at the same time.
How to easily make it thread-safe?
In general try to use pure 'functions' or methods with immutable data structures that should help with thread safety.