Monday, December 28, 2015

Threads and how to use

Use this class when you want to have an Objective-C method run in its own thread of execution. Threads are especially useful when you need to perform a lengthy task, but don’t want it to block the execution of the rest of the application. In particular, you can use threads to avoid blocking the main thread of the application, which handles user interface and event-related actions. Threads can also be used to divide a large job into several smaller jobs, which can lead to performance increases on multi-core computers.
Two ways to create threads…
·         detachNewThreadSelector:toTarget:withObject:
·         Create instances of NSThread and start them at a later time using the “start” method.
NSThread is not as capable as Java’s Thread class, it lacks
·         Built-in communication system.
·         An equivalent of “join()”