Operating Systems: Three Easy Pieces - Condition Variables
아쉽게도 lock만으로는 동시 프로그램을 구축하는 데 제약이 있습니다. 특히 스레드가 실행을 계속하기 전에 조건이 참인지 확인을 하고 싶어하는 경우가 많은 데, 이를 해결할 때 부족한점이 보이죠. 예를 들어 부모 스레드는 자식 스레드가 완료되었는 지 여부를 확인하고 싶을 수 있죠.(이를 join으로 부르기도 합니다.) import threading def child(): print("child") # XXX how to indicate we are done? def main(): print("parent: begin") t = threading.Thread(target=child) t.start() # XXX how to wait for child? print("parent: end") if __name__ == "__main__": main() 위 코드는 실행하면 아래처럼 부모가 먼저 끝날 수 있습니다. ...