ThreadWait
Waits until the designated thread has been completed before returning
Syntax
`
Declare Sub ThreadWait ( ByVal id As Any Ptr )
`
Usage
`
ThreadWait( id )
`
Parameters
`id`
`Any Ptr` handle of a thread created by `ThreadCreate`
Description
`Threadwait` doesn't return until the thread designated by `id` ends. `Threadwait` does not force the thread to end; if a thread requires a signal to force its end, a mechanism such as shared variables must be used.
Threads are launched by the `ThreadCreate` function.
To avoid simultaneous access to shared resources from different threads, FreeBASIC implements mutexes, mutual exclusion locks that can be "owned" by a single thread when doing critical work. See `MutexCreate`, `MutexLock`, `MutexUnlock`, `MutexDestroy`
Example
See the `ThreadCreate` examples.
Dialect Differences

- Threading is not allowed in the -lang qb dialect.

Platform Differences

- Threadwait is not available with the DOS version of FreeBASIC, because multithreading is not supported by DOS kernel nor the used extender.
- In Linux the threads are always started in the order they are created, this can't be assumed in Win32. It's an OS, not a FreeBASIC issue.

Differences from QB

- New to FreeBASIC

See also

- `ThreadCreate`
- `MutexCreate`
- `MutexLock`
- `MutexUnlock`
- `MutexDestroy`