# exit_thread

Definition: | exit_thread(integer exitcode)
Description: | Terminate execution of the current thread.
pwa/p2js: | Not supported.
Comments: | Just as abort() terminates the entire application (and will still do so even if invoked from a worker thread), exit_thread() terminates the current thread, and can safely be invoked even several levels deep in nested calls. Note that exit_thread() must be avoided at all costs when multitasking is in use, as per suspend_thread(). Properly written code should use an exitcode of 0 and send appropriate messages on failure before terminating. An idle wait_thread() is properly signalled following an exit_thread(). However, should you really want to monitor/poll active threads, the exit code can be retrieved via get_thread_exitcode(). There will of course be times when such a more obvious quick and dirty way is entirely appropriate. While the thread is still active, get_thread_exitcode returns STILL_ACTIVE (=259), so obviously that particular value should be avoided.
Implementation: | See builtins\VM\pThreadN.e (an autoinclude) for details of the actual implementation.
See Also: | abort, multitasking, suspend_thread, get_thread_exitcode, wait_thread