- Tìm số 0 đầu tiên trong một mảng bit
- Unix Hiển thị thông tin về các tập tin khớp với một trong hai mẫu
- Biểu thức chính quy thay thế nhiều tệp
- Ẩn lệnh từ xtrace
python中的thread.start_new_thread
Vàthreading.Thread.start
Sự khác biệt là gì?
我注意到,当调用 start_new_thread
时,新线程会在调用线程终止后立即终止。 threading.Thread.start
则相反:调用线程等待其他线程终止。
1 Câu trả lời
chủ đề
模块是 Python 的低级线程 API。除非您确实需要,否则不建议直接使用它。 xâu chuỗi
模块是一个高级 API,构建在 chủ đề
之上。 Thread.start
方法实际上是使用thread.start_new_thread
实现的。
Chủ đề
củadaemon
属性必须在调用bắt đầu
之前设置,指定线程是否应该是守护进程。当没有留下任何事件的非守护线程时,整个 Python 程序就会退出。默认情况下,daemon
vì SAI
,因此该线程不是守护进程,因此该进程将等待其所有非守护线程退出,这是您的行为正在观察。
附言start_new_thread
真的很底层。它只是 Python 核心线程启动器的一个薄包装,它本身调用操作系统线程生成函数。
关于python - thread.start_new_thread 与 threading.Thread.start,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5882362/
当我单独运行下面的函数时,它会在 3 秒后退出,但是当我在线程中调用它时,它永远不会退出。请提出这段代码中的错误。 def display(val1, val2): root = Tk()
fdict= {0: fun1(), 1: fun2()} # approach 1 : working fine, printing string print fdict[random.randi
使用线程库时,有没有办法加入由 start_new_threads 创建的所有线程? 例如: try: import thread except ImportError: imp
我在 https://code.google.com/p/pyloadtools/wiki/CodeTutorialMultiThreading 找到了这个简单的代码 import _thread d
尝试在 Python 中使用 thread 时,使用以下代码 import select, sys, time, thread TIMEOUT = 30 def listenthread(server
当我使用旧的 Python thread API 时一切正常: thread.start_new_thread(main_func, args, kwargs) 但如果我尝试使用新的 threadin
Sự khác biệt giữa thread.start_new_thread và threading.Thread.start trong Python là gì? Tôi nhận thấy rằng khi start_new_thread được gọi, luồng mới sẽ bị chấm dứt khi luồng gọi
我正在学习有关简单线程的教程。他们给出了这个例子,当我尝试使用它时,我从解释器那里得到了无法理解的错误。你能告诉我为什么这不起作用吗?我在 WinXP SP3 w/Python 2.6 current
Tôi là một lập trình viên xuất sắc, rất giỏi!