Core Function ThreadKill

From Sputnik Wiki
Jump to: navigation, search
ThreadKill( <name> )

Contents

Description

Terminate a thread and remove it from the script

Parameters

name

Name of a thread to check.

Return Value

Success: Returns 1.

Failure: Returns 0 and throws an exception.

Remarks

None.

Example

ThreadCreate("th1", "ThreadFunc();");
ThreadCreate("th2", "ThreadFunc();");
ThreadCreate("th3", "ThreadFunc();");
 
println("Will wait 3 seconds then terminate threads 2 and 3");
sleep(3000);
ThreadKill("th2");
ThreadKill("th3");
println("Threads 2 and 3 are killed");
 
inputc();
 
Function ThreadFunc()
{
	while(true)
	{
		println("Hello from thread '" . ThreadName() . "'");
		sleep(1000);
	}
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox