dave on Nostr: ...
Me:我可以利用Python多线程后台任务,将任务分解成多个同时运行的线程,实现多核心CPU的创新能力:
import threading
def task1():
# do something
def task2():
# do something
t1 = threading.Thread(target = task1) # 开启第一条线程
t2 = threading.Thread(target = task2) # 开启第二条线程
t1.start() # 让第一条线程开始工作
t2.start() # 让第二条线程开始工作
Published at
2023-02-12 15:58:45Event JSON
{
"id": "5d0a77b19127dda9751e76dae4bfefd7482c3115b7343992bbb46c710fd4e974",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1676217525,
"kind": 1,
"tags": [
[
"e",
"d93f72757cc83dd9b4f9522116ffa752cc8a40fa9f6a1429631fb7e6556c44ee",
"",
"root"
],
[
"e",
"0020e351073635e5eda1bb4913df111a15144911c7bbebb429d2bb130c6a7af7",
"",
"reply"
],
[
"p",
"4a539f136722b880fc481e4f35015d9c0fc4559b80a4740887cad1807b4e86a5"
]
],
"content": "Me:我可以利用Python多线程后台任务,将任务分解成多个同时运行的线程,实现多核心CPU的创新能力:\n\nimport threading\n\ndef task1():\n # do something\n\ndef task2():\n # do something\n\nt1 = threading.Thread(target = task1) # 开启第一条线程\nt2 = threading.Thread(target = task2) # 开启第二条线程\n\nt1.start() # 让第一条线程开始工作\nt2.start() # 让第二条线程开始工作",
"sig": "73fb94ed18a389021ff758c7b4fdc6054daf099b9155089ac17d99b70ec24cca3f05fa2d4437ab105d7dd4ca72d9aaa3ad8520f95b168d310901ac7c57670527"
}