python-多线程(原理篇)
多线程的基本概念
语言学习总是绕不过一些东西,例如多进程和多线程,最近越来越发现,上来看几个实例练习一下过几天就不知其所以然了。所以还是先看看原理,在看实例练习吧!
线程的概念
概念:线程是进程中执行运算的最小单位,是进程中的一个实体,是被系统独立调度和分派的基本单位,线程自己不拥有系统资源,只拥有一点在运行中必不可少的资源,但它可与同属一个进程的其它线程共享进程所拥有的全部资源。一个线程可以创建和撤消另一个线程,同一进程中的多个线程之间可以并发执行。其实平时我们启动程序,其实是启动的进程,但是在往下细分的话,其实是进程的一个或者多个线程完成的功能。
好处 :(1)易于调度。
(2)提高并发性。通过线程可方便有效地实现并发性。进程可创建多个线程来执行同一程序的不同部分。
(3)开销少。创建线程比创建进程要快,所需开销很少。
(4)利于充分发挥多处理器的功能。通过创建多线程进程,每个线程在一个处理器上运行,从而实现应用程序的并发性,使每个处理器都得到充分运行。
多线程vs多进程
操作系统会为每个进程分配不同的内存块,而多个线程共享进程的内存块。这带来最直接的不同就是创建线程的开销远小于创建进程的开销。
同时,由于内存块不同,所以进程之间的通信相对困难。而线程间的通信简单快速,就是共享进程内的全局变量。
但是,进程的调度由操作系统负责,线程的调度需要我们自己来考虑,避免死锁,饥饿,活锁,资源枯竭等情况的发生,这会增加一定的复杂度,这会增加一定的复杂度。而且,由于线程之间共享内存,我们还需要考虑线程安全性的问题。
线程安全
以为线程间共享进程中的全局变量,所以当其他线程改变了共享的变量时,可能会对本线程产生影响。所谓线程安全的约束是指一个函数被多个并发线程反复调用时,要一直产生正确的结果。要保证线程安全,主要是通过加锁的方式保证共享变量的正确访问。
比线程安全更严格的约束是‘可重入性’,即函数在一个线程内执行的工程中被暂停,接下来又在另一个线程内被调用,之后在返回原线程继续执行。在整个过程中都能保证正确执行。保证可重入性,通常通过制作全局变量的本地拷贝来实现。
线程的生命周期
线程的生命周期如下图所示
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtEAAAEkCAIAAABmHPpnAAAgAElEQVR4nO2dbWxU15nH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8DmAJIOqDzs+QAAAAASUVORK5CYII=" alt="" />
各个状态的说明如下:
1.new新建。新创建的线程经过初始化后,进入Runnable状态。
2.Runnable就绪。等待线程调度。调度后进入运行状态。
3.Running运行。
4.Blocked阻塞,暂停运行,解除阻塞后进入Runnable状态重新等待调度。
5.Dead消亡。线程方法执行完毕返回或者异常终止。
可能有3种情况从Running进入Blocked:
同步:线程中获取同步锁,但是资源已经被其他线程锁定时,进入Locked状态,直到该资源可获取(获取的顺序由Lock队列控制)
睡眠:线程运行sleep()或join()方法后,线程进入Sleeping状态。区别在于sleep等待固定的时间,而join是等待子线程执行完。当然join也可以指定一个“超时时间”。从语义上来说,如果两个线程a,b, 在a中调用b.join(),相当于合并(join)成一个线程。最常见的情况是在主线程中join所有的子线程。
等待:线程中执行wait()方法后,线程进入Waiting状态,等待其他线程的通知(notify)。
线程的类型
主线程:当一个程序启动时,就有一个进程被操作系统(OS)创建,与此同时一个线程也立刻运行,该线程通常叫做程序的主线程(Main Thread)。每个进程至少都有一个主线程,主线程通常最后关闭。
子线程:在程序中创建的其他线程,相对于主线程来说就是这个主线程的子线程。
守护线程:daemon thread,对线程的一种标识。守护线程为其他线程提供服务,如JVM的垃圾回收线程。当剩下的全是守护线程时,进程退出。
前台线程:相对于守护线程的其他线程称为前台线程。
python-多线程(原理篇)的更多相关文章
- Python多线程原理与实现
Date: 2019-06-04 Author: Sun Python多线程原理与实战 目的: (1)了解python线程执行原理 (2)掌握多线程编程与线程同步 (3)了解线程池的使用 1 线程基本 ...
- Python多线程多进程那些事儿看这篇就够了~~
自己以前也写过多线程,发现都是零零碎碎,这篇写写详细点,填一下GIL和Python多线程多进程的坑~ 总结下GIL的坑和python多线程多进程分别应用场景(IO密集.计算密集)以及具体实现的代码模块 ...
- Python 第八篇:异常处理、Socket语法、SocketServer实现多并发、进程和线程、线程锁、GIL、Event、信号量、进程间通讯
本节内容: 异常处理.Socket语法.SocketServer实现多并发.进程和线程.线程锁.GIL.Event.信号量.进程间通讯.生产者消费者模型.队列Queue.multiprocess实例 ...
- python多线程、多进程以及GIL
多线程 使用threading模块创建线程 传入一个函数 这种方式是最基本的,即调用threading中的Thread类的构造函数,然后指定参数target=func,再使用返回的Thread的实例调 ...
- Python 多线程、多进程 (一)之 源码执行流程、GIL
Python 多线程.多进程 (一)之 源码执行流程.GIL Python 多线程.多进程 (二)之 多线程.同步.通信 Python 多线程.多进程 (三)之 线程进程对比.多线程 一.python ...
- xgboost入门与实战(原理篇)
sklearn实战-乳腺癌细胞数据挖掘 https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campai ...
- python 多线程探索
前面已经了解过了,python多线程效率较低的主要原因是存在GIL,即Global Interpreter Lock(全局解释器锁).这里继续详细的看下GIL的说明与如何避免GIL的影响,从而提高py ...
- python多线程同步实例分析
进程之间通信与线程同步是一个历久弥新的话题,对编程稍有了解应该都知道,但是细说又说不清.一方面除了工作中可能用的比较少,另一方面就是这些概念牵涉到的东西比较多,而且相对较深.网络编程,服务端编程,并发 ...
- python 多线程,tthread模块比较底层,而threading模块是对thread做了一些包装,multithreading
Python多线程详解 2016/05/10 · 基础知识 · 1 评论· 多线程 分享到:20 本文作者: 伯乐在线 - 王海波 .未经作者许可,禁止转载!欢迎加入伯乐在线 专栏作者. 1.多线程的 ...
- Cesium原理篇:7最长的一帧之Entity(下)
上一篇,我们介绍了当我们添加一个Entity时,通过Graphics封装其对应参数,通过EntityCollection.Add方法,将EntityCollection的Entity传递到DataSo ...
随机推荐
- ASP.NET 短路由配置
1. 首先在项目新建文件叫App_Code或者App_Start 在文件中新建WebFromRouteHandler.cs 文件. WebFromRouteHandler中的代码如下, public ...
- Oracle EBS-SQL (INV-12):检查待定事物处理1.sql
/*未加工物料*/ update inv.mtl_material_transactions_temp set process_flag='Y', LOCK_FLAG='N', TRANSACTION ...
- Oracle EBS-SQL (PO-15):检查不能审批的PO.sql
SELECT PHA.SEGMENT1, PHA.WF_ITEM_KEY, PHA.* FROM PO.PO_HEADERS_ALL PHA WHERE PHA.AUTHORIZATION_STA ...
- .NET设计模式系列文章
原文地址:http://terrylee.cnblogs.com/archive/2006/06/01/334911.html 最初写探索设计模式系列的时候,我只是想把它作为自己学习设计模式的读书笔记 ...
- eclipse sysout快捷输入启用
Window-Preference-java-editor-content assist-advanced 一定要勾选Template Propasals. 关于Template Propasals: ...
- C#基础:委托 【转】
委托是C#中最为常见的内容.与类.枚举.结构.接口一样,委托也是一种类型.类是对象的抽象,而委托则可以看成是函数的抽象.一个委托代表了具有相同参数列表和返回值的所有函数.比如: delegate in ...
- Stopwatch 类【转】
一般我们想要测试使用那种方法或着那种类型效率更高,使用Stopwatch类进行测试就可以,我也是现在才知道,汗一个. 先来看个小示例,如下. 前提,先引用using System.Diagnostic ...
- JAVA Socket连接服务器时可能抛出的异常
1.UnknownHostException:host(非ip)无法识,就会报该异常,www.google.com.hk这个虽然也ping不通,但是不会报该错,因为他是一个确实存在的域名.他会报Con ...
- LinQ学习手册
LinQ : Language Integrated Query(语言集成查询); 1.以统一方式操作各种数据源,减少数据访问的复杂性. 优点在于封装了SQL语句,只对对象进行操作(增删改查),代码量 ...
- 从头开始-03.C语言中数据类型
基本数据类型 整形: Int 4字节 %d / %i Short 2字节 %hd Long 8字节 %ld Longlong 8字节 %lld Unsigned 4字节 % 浮点型 单精度 Float ...