Join Smalltalk等待活动进程

Join Smalltalk等待活动进程,join,process,wait,smalltalk,Join,Process,Wait,Smalltalk,我有以下代码: newProc := [self doSth] newProcess. newProc resume. self doOtherJob. newProc wait. "<- here is the question" newProc:=[self doSth]newProcess。 新程序恢复。 自我毁灭的工作。 newProc等待。“最初由卡米洛·布鲁尼创作: 信号灯是你的朋友: semaphore := Semaphore new. [ ... First Job

我有以下代码:

newProc := [self doSth] newProcess.
newProc resume.
self doOtherJob.
newProc wait. "<- here is the question"
newProc:=[self doSth]newProcess。
新程序恢复。
自我毁灭的工作。

newProc等待。“最初由卡米洛·布鲁尼创作:

信号灯是你的朋友:

semaphore := Semaphore new.

[ ... First Job ...
    semaphore signal. ] fork.

[ ... Second Job ...
    semaphore signal. ] fork.

"consume to signals, aka. pause this thread until both jobs have finished"
semaphore wait; wait.
在您的情况下,您必须:

semaphore := Semaphore new.
newProc := [
    self doSth.
    semaphore signal ] newProcess.
newProc resume.
self doOtherJob.
semaphore wait.

可能使用带有超时的信号量来确保信号量最终会发出信号。如何在不阻塞负责用户界面的主线程的情况下获得此功能?@AMomchilov您只需将所有内容包装在一个块中并发送它
fork
。信号量等待将在过程中发生,而不是在您的主UI中ocessHah是的,我明白了!:)我没想清楚,哈哈