{{fbdoc item="title" value="THREADWAIT"}}----
Waits for a thread to finish execution and releases the thread handle

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare Declare]] [[KeyPgSub Sub]] **""ThreadWait""** ( [[KeyPgByval Byval]] //id// [[KeyPgAs As]] [[KeyPgAny Any]] [[KeyPgPtr Ptr]] )
##
{{fbdoc item="usage"}}##
	**""ThreadWait""**( //id// )
##
{{fbdoc item="param"}}
	##//id//##
		##[[KeyPgAny Any]] [[KeyPgPtr Ptr]]## handle of a thread created by ##[[KeyPgThreadCreate ThreadCreate]]## or ##[[KeyPgThreadCall ThreadCall]]##

{{fbdoc item="desc"}}
	**""ThreadWait""** waits for a thread created by ##[[KeyPgThreadCreate ThreadCreate]]## or ##[[KeyPgThreadCall ThreadCall]]## to finish execution, and then releases the resources associated with the thread handle. **""ThreadWait""** does not return until the thread designated by ##//id//## ends. 
	
	In order to release a thread handle without waiting for the thread to finish, use ##[[KeyPgThreadDetach ThreadDetach]]##.
	
	**""ThreadWait""** 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.

{{fbdoc item="ex"}}
	See the ##[[KeyPgThreadCreate Threadcreate]]## examples.

{{fbdoc item="lang"}}
	- Threading is not allowed in the //[[CompilerOptlang -lang qb]]// dialect.

{{fbdoc item="target"}}
	- **""ThreadWait""** is not available with the DOS version of ""FreeBASIC"", because multithreading is not supported by DOS kernel nor the used extender.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgThreadCreate ThreadCreate]]##
	- ##[[KeyPgThreadDetach ThreadDetach]]##

{{fbdoc item="back" value="CatPgThreading|Threading Support Functions"}}