java线程和操作系统线程_操作系统中的线程
java線程和操作系統(tǒng)線程
線程數(shù) (Threads)
A thread is a unit of CPU utilization, which comprises the following parts that are program counter, register set, stack and a thread ID. Generally, it’s well known that the process is heavy weighted which means they consume lot more resources than the threads, and in this threads are light weighted. Basically, there are two types of threading process are there which are as follows:
線程是CPU利用率的單位,包括以下部分:程序計(jì)數(shù)器,寄存器集,堆棧和線程ID。 通常,眾所周知,進(jìn)程的權(quán)重很重,這意味著它們比線程消耗更多的資源,而在這種情況下,線程的權(quán)重很輕。 基本上,有兩種類型的線程處理過(guò)程,如下所示:
Single Threaded process:
單線程進(jìn)程:
Traditionally if a process has a single thread of control then it is termed as a single threaded process.
傳統(tǒng)上,如果進(jìn)程具有單控制線程,則將其稱為單線程進(jìn)程。
Multi Threaded process:
多線程進(jìn)程:
If a process has multiple threads of control then it is termed as a Multithreaded process. It can be used to perform multiple tasks at a single time.
如果一個(gè)進(jìn)程具有多個(gè)控制線程,則將其稱為多線程進(jìn)程。 它可以一次執(zhí)行多個(gè)任務(wù)。
Thread also plays a vital role in RPC which means Remote procedure call. It is used to call a function of some another program. The thread can also be used for the interprocess communication.
線程在RPC中也起著至關(guān)重要的作用,這意味著遠(yuǎn)程過(guò)程調(diào)用。 它用于調(diào)用另一個(gè)程序的功能。 該線程也可以用于進(jìn)程間通信。
多線程編程的好處 (Benefits of Multi-Threaded programming)
Responsiveness:
響應(yīng)能力:
Since multithreading is an application which will allow a program to run even when a part of it is blocked. So it will increase the responsiveness to the particular user. For example suppose that a particular section is not responding in the above Multi-Threaded diagram instead of an entire process not responding, the two sections can respond to the user, which means Responsiveness.
由于多線程是一個(gè)應(yīng)用程序,即使其中一部分被阻止,它也將允許程序運(yùn)行。 因此,它將增加對(duì)特定用戶的響應(yīng)。 例如,假設(shè)在上面的多線程圖中特定部分沒(méi)有響應(yīng),而不是整個(gè)過(guò)程沒(méi)有響應(yīng),則這兩個(gè)部分可以響應(yīng)用戶,這意味著響應(yīng)性。
Resource sharing:
資源共享:
It is a beneficial part in case of Multi-Threaded programming as it allows an application to have several different threads of venture within the same address space.
在多線程編程的情況下,它是有益的部分,因?yàn)樗试S應(yīng)用程序在同一地址空間內(nèi)具有多個(gè)不同的冒險(xiǎn)線程。
Boom Throughput:
動(dòng)臂吞吐量:
Number of jobs completed per unit time is increased which is a favorable condition.
每單位時(shí)間完成的作業(yè)數(shù)量增加,這是一個(gè)有利條件。
Communication:
通訊:
As different threads have the same address space so it is very easier to communicate with the Multiple-Thread.
由于不同的線程具有相同的地址空間,因此與多線程通信非常容易。
Economy:
經(jīng)濟(jì):
As we know that threads share resources of the process for which they belong, by this it will be more economical to create threads for data and resource sharing.
眾所周知,線程共享它們所屬進(jìn)程的資源,因此,創(chuàng)建用于數(shù)據(jù)和資源共享的線程將更加經(jīng)濟(jì)。
Utilization of the Multiprocessor architectures:
多處理器體系結(jié)構(gòu)的利用:
The benefits of Multi-Threading can be increased in an architecture which means threads can be made to run in parallel on a different processor, thus there will increment in a concurrency level.
在體系結(jié)構(gòu)中可以增加多線程的好處,這意味著可以使線程在不同的處理器上并行運(yùn)行,因此并發(fā)級(jí)別會(huì)增加。
多線程模型 (Multithreading Models)
Generally, there are two types of threads which are user thread and another one is kernel thread. In this type of system, the user-level threads are supported above the kernel and managed without kernel support, whereas kernel threads are directly supported and managed by the help of an operating system. On the basis of it there are generally three types of model governed:
通常,有兩種類型的線程是用戶線程,另一種是內(nèi)核線程。 在這種類型的系統(tǒng)中,用戶級(jí)線程在內(nèi)核之上受支持并且在沒(méi)有內(nèi)核支持的情況下進(jìn)行管理,而內(nèi)核線程在操作系統(tǒng)的幫助下直接得到支持和管理。 在此基礎(chǔ)上,通常管理三種類型的模型:
Many to One model
多對(duì)一模型
In this mapping is done between the many user-level threads to the one kernel thread. So in this, we have many user levels which are mapped with one kernel thread.
在這種情況下,映射是在許多用戶級(jí)線程到一個(gè)內(nèi)核線程之間完成的。 因此,在此,我們有許多用戶級(jí)別,它們被一個(gè)內(nèi)核線程映射。
One to One Model
一對(duì)一模型
In this mapping is done between each user thread and the kernel thread.
在此,在每個(gè)用戶線程和內(nèi)核線程之間完成映射。
Many to Many Model
多對(duì)多模型
It is a type of model in which it multiplexes many user-level threads to a smaller or equal number of kernel threads. In this, if we have four user threads than we can have either four or less than four kernel thread.
它是一種模型,其中它將許多用戶級(jí)線程多路復(fù)用為更少或相等數(shù)量的內(nèi)核線程。 在這種情況下,如果我們有四個(gè)用戶線程,那么我們可以有四個(gè)或少于四個(gè)內(nèi)核線程。
翻譯自: https://www.includehelp.com/operating-systems/threading.aspx
java線程和操作系統(tǒng)線程
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的java线程和操作系统线程_操作系统中的线程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: stringreader_Java St
- 下一篇: 数据库数据规范化看不懂_数据库管理系统中