摘要:
一、多个线程对同一个数据进行修改 from threading import Thread,Lock n = 0 def add(lock): for i in range(500000): global n with lock: n += 1 def sub(lock): for i in ran 阅读全文
摘要:
import time from threading import Thread def son(): while True: print('in son') time.sleep(1) def son2(): for i in range(3): print('in son2 ****') tim 阅读全文
摘要:
一、创建自定义线程类继承Thread 自定义线程类代码 package com.demo05; public class MyThread extends Thread { @Override public void run() { for (int i = 0; i < 20; i++) { Sy 阅读全文