| Start |
|---|
| Basic Thread Semantics A new thread separate from the main thread's execution, can be created using This will automatically start the execution of the new thread. To freeze execution of the main Thread, until the new thread stops, use Note that the Thread may have already finished when you call join, in which case execution will continue normally. If a sub-thread is never joined, and the main thread completes, the sub-thread will not execute any remaining code. |
| Accessing shared resources Use a mutex to synchronise access to a variable which is accessed from multiple threads: Otherwise, the value of Example without Example with |
| How to kill a thread You call use |
| Terminating a Thread A thread terminates if it reaches the end of its code block. The best way to terminate a thread early is to convince it to reach the end of its code block. This way, the thread can run cleanup code before dying. This thread runs a loop while the instance variable continue is true. Set this variable to false, and the thread will die a natural death: |
Read Article
https://develop.horje.com/learn/1434/reference