02 2021 档案

摘要:线程池 from concurrent.futures import ThreadPoolExecutor,as_completed import time #为什么要线程池 #主线程可以获取某一个线程的状态或者某一个任务的状态,以及返回值 #当一个线程完成的时候,主线程立马知道 #funtures 阅读全文
posted @ 2021-02-07 14:19 Mr.zou 阅读(60) 评论(0) 推荐(0) 编辑
摘要:多态和多态性 import abc #多态 #多态是指一类事物有多种形态,比如动物类,可以有猫,狗,猪等等。(一个抽象类有多个子类,因而多态的概念依赖于继承) class Animal(metaclass=abc.ABCMeta): #同一类事物:动物 @abc.abstractmethod def 阅读全文
posted @ 2021-02-05 11:40 Mr.zou 阅读(203) 评论(0) 推荐(0) 编辑
摘要:互斥锁 from threading import Thread,Lock import os,time #互斥锁 def work(): global n lock.acquire() # 锁住n,让他依次执行 temp = n print(n) time.sleep(0.1) n=temp-1 阅读全文
posted @ 2021-02-04 17:42 Mr.zou 阅读(276) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python #-*- coding: utf-8 -*- from time import ctime, sleep import threading import time loops = ['江西', '吉安'] class MyThread(threading. 阅读全文
posted @ 2021-02-03 16:43 Mr.zou 阅读(190) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示