#Thread.start() //thread start #Thread.run() //thread main function run #Thread.join([timeout]) //wait until thread end from threading import Thread, Lock import time count = 10 lock = Lock() class developer(Thread): def __init__(self, name): #initialize Thread.__init__(self) self.name = name self.fixed = 0 def run(self): #thread main function global count while 1: #lock.acquire() #lock -> Untie comment, error occurs, I don't know why error occurs... if count > 0: count -= 1 #lock.rlease() #unlock -> Untie comment, error occurs, I don't know why error occurs... self.fixed += 1 time.sleep(0.1) else: #lock.release() #unlock -> Untie comment, error occurs, I don't know why error occurs... break dev_list = [] for name in ['Mare1', 'Mare2', 'Mare3']: dev = developer(name) #create thread dev_list.append(dev) dev.start() #thread start for dev in dev_list: dev.join() #wait print(dev.name, 'fixed', dev.fixed) #Mare1 fixed 3 #Mare2 fixed 4 #Mare3 fixed 3
3/18/2014
Python Study, Threading example source code
-
CUDA_ARCH_BIN Table for gpu type Jetson Products GPU Compute Capability Jetson AGX Xavier 7.2 Jetson Nano 5.3 Jetson TX2 6.2 Jetson TX1 5.3 ...
-
put a explicit parameter name like: from sklearn.utils import class_weight class_weights = class_weight.compute_class_weight( class_weight...
-
look at the code! ^^ .. #load image tif_path = './input_img.tif' #open image pil_image = Image. open ( tif_path ) #change dpi in...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv <-> rgb converting example code. refer to this page -> ht...
-
This is dithering example, it make image like a stippling effect. I referenced to blew website. wiki page: https://en.wikipedia.org/wik...
-
make well divided linear coordinate And make pair coordinate Please see code for detail explanation. import numpy as np import cv2 ...
-
input image output image source code import cv2 as cv import numpy as np import sys import random #read image img = ...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
Just see the code It's not difficult. ... ... import cv2 import numpy as np ... def lambda_handler(event, context): # TODO i...