Multithreading
Threads: a thread is a “light-weight” process
- It is a unit of execution within a given process (a process may have several threads)
- Each thread in a process shares the memory(except stack) and resources while processes don’t share memory.
- Creating a new thread requires fewer resources than creating a new process.
Time-Slicing Algorithm
Processing time for a single core is shared among processes and threads.
![](E:\wztblog\source\img\Pasted image 20210223163210.png)
THREAD STATES
NEW
: Instantiate a thread. We use start() method.Runnable
: After we have started the thread.The thread is executing.Waiting
: A thread waits for other threads to finish. Usewait()
,sleep()
method. Can be waken up by other threads.Dead
After the thread finished its task.
- Post link: http://wangzt568.github.io/2021/02/23/MultithreadingBasicTheory/
- Copyright Notice: All articles in this blog are licensed under unless otherwise stated.
若没有本文 Issue,您可以使用 Comment 模版新建。
GitHub Issues