📜  多任务和多线程的区别

📅  最后修改于: 2021-09-11 04:43:04             🧑  作者: Mango

先决条件——多道程序、多任务、多线程和多处理
多任务处理:
多任务是指提供一个 CPU 一次执行多个任务。多任务处理通常涉及任务之间的 CPU 切换,以便用户可以与每个程序一起协作。与多线程不同,在多任务中,进程共享单独的内存和资源。由于多任务涉及 CPU 在任务之间快速切换,因此从一个用户切换到下一个用户只需要很少的时间。

多线程:
多线程是一种系统,在该系统中,从一个进程中创建了许多线程,通过该进程可以增加计算机的能力。在多线程中,提供CPU是为了一次从一个进程中执行多个线程,而在多线程中,进程的创建是根据成本进行的。与多任务不同,多线程为进程提供相同的内存和资源以供执行。

让我们看看多任务和多线程之间的区别:

S.NO Multitasking Multithreading
1. In multitasking, users are allowed to perform many tasks by CPU. While in multithreading, many threads are created from a process through which computer power is increased.
2. Multitasking involves often CPU switching between the tasks. While in multithreading also, CPU switching is often involved between the threads.
3. In multitasking, the processes share separate memory. While in multithreading, processes are allocated same memory.
4. Multitasking component involves multiprocessing. While multithreading component does not involve multiprocessing.
5. In multitasking, CPU is provided in order to execute many tasks at a time. While in multithreading also, CPU is provided in order to execute many threads from a process at a time.
6. In multitasking, processes don’t share same resources, each process is allocated separate resources. While in multithreading, each process share same resources.
7. Multitasking is slow compared to multithreading. While multithreading is faster.
8. In multitasking, termination of process takes more time. While in multithreading, termination of thread takes less time.