KillThread()

Syntax

KillThread(ThreadID)
Description
Imediately kills the specified thread, which had previously been created with CreateThread(). This is a very dangerous function, don't use it if possible. The problem is that the thread is killed immediately and has no chance to perform any cleanup code (for example, freeing memory, releasing items, de-allocating its own stack).

Parameters:
ThreadID - The ID number of the thread that you want to kill. This value is returned by CreateThread().


Return value:
This command does not return a value.


Example:
Procedure PrintStuff(interval.l)
    Repeat
        Print(".")
        Delay(interval)
    ForEver
EndProcedure

If OpenConsole()
    thid.l = CreateThread(@PrintStuff(), 500)
    If thid
        For i=0 To 10
            Print("A")
            Delay(999)

            If i=5
                KillThread(thid)
            EndIf
        Next
    EndIf
EndIf
End

Supported OS

Windows, Linux, MacOS X

<- CreateThread() - Thread Index - PauseThread() ->