On Jan 6, 2007, at 2:32 PM, Stefan wrote:

A main worker Thread A need to kick of a sub-worker Thread B and wait
for its termination.

Currently, A calls B.Run() and performs A.Suspend(). If B finishes, it performs
A.Resume().

If B is quite fast, this may generate an ugly race condition: B resumes A, but A hasn't yet suspended. Even worse, A would suspend, once B resumed it. Quite dead..

Thus, I feel a semaphore or such like is required. I suppose, I need an atomic action,
which suspends A and - in parallel - restarts B.

Since I didn't find an RB solution, does someone has a snippet or a good hint?

Don't suspend A.  Instead, follow B.Run with

do
  A.Sleep
  if B.State = Thread.NotRunning then
    exit
  end if
loop

Or pass a reference to A to B, and block B.Run until it confirms that A is suspended.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to