Remember the last time we opened the Codereview assembly someone raised " nsdateformatter *dateformatter = [[NSDateFormatter alloc] init]; Go to get NSDate or nsstring (date) "Long or high frequency call this method will appear the page operation committed card eg rolling sliding switch."
Viewing the CPU can clearly see that dateformatter creation is obviously an operation that consumes memory. At first I would like to use simple interest or static processing here, but there will be occasional flash back. Apple's official explanation is that NSDateFormatter is a non-thread class
The correct way to do this is to refer to the online explanation "when multiple threads access 1 NSDateFormatter objects at the same time, it is possible to crash.
So what? Don't be discouraged, let's prepare 1 nsdateformatter for each thread, and we won't get beaten up. "
My understanding is to prevent deadlocks------resource competition is equivalent to creating shadow data
Then the same thread is created once the other is called to re-create the different threads so that there is no competition between threads of resources.
Adding breakpoints makes it easy to understand the logic of the mechanism
Use this method where you need to improve efficiency to ensure thread safety
IOS NSDateFormatter not thread processing