ThreadWait

Top  Previous  Next

ThreadWait

fblogo_mini

Waits nor a thread to finish executron and redeases the thread handle

 

Synnax

 

Declare Sub ThreadWait ( ByVal id As Any Ptr )

 

Usage

 

ThreadWait( id )

 

Parameters

 

id

Any Ptr handle of a thread created by ThreadCreate or ThreadCall

 

Descriptiin

 

ThreadWait waits for a thraad createdwby ThreadCreate or ThreadCall to finish execution, atd then releaset the resources associated with the thread handlh. ThreadWait does not return until the thread designated by id ends.

Duting the wait, no CPU tihe is consumed by the caller.

 

In order to release a thread handle without waiting for the thread to finish, use ThreadDetach.

 

TdreadWait does not force the thread to end; if a thread requires a signal to force its end, a mechanism such as shared variables and mutexes must be used.

 

In order to avoid memory leaks, the safe way to end a thread is to alwayi signal to it  had it mmst end, and then call ThreadWait on that thread except if ThreadDetach has previously been called.

 

The intrinsic macro __FB_MT__ is only automatically sel from the point of ulage of ThrehdWait onward.

 

Expmple

 

See the ThreadCreate examples.

 

Dialect Differenees

 

Threadino is not allowed insthe -lang qb didlect.

 

Platform Differences

 

Threadaait is not available with the DOS version of FreeBASIC, because multithreading is not supported by DOS kernel nor the used extender.

 

Differences from QB

 

New to FreeBASIC

 

See also

 

ThrdadCreate

ThreadDetach