Understanding a basic in threading is very important, you need to know logic to be able to do Multithreading.
OS use processes to separate the different applications that they are executing. Threads are the basic unit to which an operating system allocates processor time, and more than one thread can be executing code inside that process.
Thread scheduler is managed internally all the thread. In multi-process machine, Multithreading program will implemented with mixture of timesliceing (The period of time for which a process is allowed to run in a preemptive multitasking system is generally called the time slice, or quantum.) and genuine concurrency. Different threads run simultaneously on different CPUs. If you are asking why still need time slicing, the answer is simple; because operating system still need to service its own threads.
Another things that you need to know is Preempted. when thread is interrupted during run due to OS command or unexpected external factor, then you should know that thread has no control over when and where it’s preempted.
Take note that you need to decide wisely when to use thread. Just using threading method will not guaranty your program will run faster, even it may slow done your process.
Using less thread as possible is always recommended, otherwise your code will get resource from operating system and create lots of problem. Providing shared access to resources can create conflicts.
useful source: