1
코드에서 일부 작업을 수행하는 작업자 스레드가 있습니다. 저작물의 데이터는이 정보를 보유하는 소규모 클래스로 수집됩니다. 이 클래스는 메인 스레드에서 처리하기 위해 큐에 넣어집니다.GC가 두 개의 스레드로 클래스 참조를 수집하는 방법
GC가이 클래스를 언제 수집합니까?
짧은 Sodu의 excample :
def run(in_q, out_q):
lp = lpClass()
# Do work and add info in class
workToDo = in_q.get_nowait()
while working:
lp.add(work data)
out_q.put_nowait(lp)
# main
t = thread(run, in_q, out_q)
t.start()
in_q.put_nowait(some work)
t.join()
while out_q.not_empty:
lp = out_q.get()
print(lp.getData())