Knowledge
Multithreading
Subject: .../Algorithms
Multi-threading suggest parallel execution of multiple threads, which causes new class of difficultires comparing to single-thread programming. To know multithreadings means knowing commong pitfalls and methods of coding around them. Usually these includes next terms: * dead-lock * live-lock * synchronization * race condition * atomicity * re-entrancy * synchronization primitives * memory barriers
Materials
Documentationby Microsoft
A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. Each process is started with a single thread, but can create additional threads from any of its threads.
Check yourself
Q:

What is the main principle of dead-lock prevention?

{ "id": "FjKjxtq0JmZgKzARplUR9hci", "question": "What is the main principle of dead-lock prevention?", "answers": [ "Always lock on no more than 1 object", "Always lock objects in the same order", "It is not possible to guarantee absense of dead-locks", "Use lock-free algorithms" ], "correctAnswers": [ "Always lock objects in the same order" ], "incorrectAnswers": [ "Always lock on no more than 1 object", "Use lock-free algorithms", "It is not possible to guarantee absense of dead-locks" ], "allowCustomAnswer": false, "canEdit": false, "allowFileAnswer": false, "multi": false, "explanation": "", "canLike": false, "likes": 0, "allAnswers": [ { "text": "Always lock on no more than 1 object", "correct": false, "selected": false }, { "text": "Use lock-free algorithms", "correct": false, "selected": false }, { "text": "It is not possible to guarantee absense of dead-locks", "correct": false, "selected": false }, { "text": "Always lock objects in the same order", "correct": true, "selected": false } ] }
Q:

How many threads can process have on CPU with 12 threads?

{ "id": "O31gXoj7IcBrIe6Lx2BTR8Zc", "question": "How many threads can process have on CPU with 12 threads?", "answers": [ "12 or 24 threads (if hyperthreading is on)", "65536 threads (64k) per CPU", "Any number - OS threads do not depend on CPU threads" ], "correctAnswers": [ "Any number - OS threads do not depend on CPU threads" ], "incorrectAnswers": [ "12 or 24 threads (if hyperthreading is on)", "65536 threads (64k) per CPU" ], "allowCustomAnswer": false, "canEdit": false, "allowFileAnswer": false, "multi": false, "explanation": "", "canLike": false, "likes": 0, "allAnswers": [ { "text": "12 or 24 threads (if hyperthreading is on)", "correct": false, "selected": false }, { "text": "Any number - OS threads do not depend on CPU threads", "correct": true, "selected": false }, { "text": "65536 threads (64k) per CPU", "correct": false, "selected": false } ] }
Do you know that ...?
- It is possible to start thread in other process

E.g. via CreateRemoteThread Win API

- Windows supports three levels of granularity of executable units

1) Process 2) Thread 3) Fiber

Skillsets
Skillset Web Backend Developer preview
image descriptionWeb Backend Developer
by Infinite Education
2091 users
Skillset Android Developer preview
image descriptionAndroid Developer
by Jack Wilson
1830 users