How to make thread safe
1.Use immutable objects
2.Use effectively immutable objects(safely published and not modifyied after constructed)
3.Use synchronize(access actions and atomic compound actions)
4.Use thread confinement
5.Delegate safety to thread safe state instance
1.Use immutable objects
2.Use effectively immutable objects(safely published and not modifyied after constructed)
3.Use synchronize(access actions and atomic compound actions)
4.Use thread confinement
5.Delegate safety to thread safe state instance