mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
We need to use old tracing function for suspending threads without breakpoint. Also sys.settrace() should be called inside a thread, that's why we pass this command as internal thread command.
26 lines
458 B
Python
26 lines
458 B
Python
from threading import Thread
|
|
from time import sleep
|
|
|
|
|
|
def print_with_pause(text, pause):
|
|
sleep(pause)
|
|
print(text)
|
|
|
|
|
|
def fun1(n):
|
|
while True:
|
|
print_with_pause("Thread1", 0.1)
|
|
|
|
|
|
def fun2(m):
|
|
sleep(2)
|
|
while True:
|
|
print_with_pause("Thread2", 0.1) # breakpoint
|
|
|
|
|
|
threads = [Thread(target=fun1, args=(24,), name="Thread1"),
|
|
Thread(target=fun2, args=(42,), name="Thread2")]
|
|
|
|
for thread in threads:
|
|
thread.start()
|