spawn Statement

Action

Begins execution of the specified statement in a new thread.

Syntax

spawn
statement
Variable Description
statement Code to run in a new thread. statement can be a single statement or a series of statements.

Notes

To create, or "spawn," multiple threads, you can use the parallel, spawn, rendezvous, and critical statements. You can use these statements to call a test case, or various test cases, on different Agents. The test cases will launch at the same time and run on their own. Note that calling multitestcase would not continue after the rendezvous statement until the last test case has finished running, meaning that the Disconnect() would not occur for any Agent until the last Agent finished.

You can spawn only one thread for a particular Agent (that is, on a particular machine).

To use a spawn statement in tests that use TrueLog Explorer, use the OPT_PAUSE_TRUELOG option to disable TrueLog Explorer. Otherwise, issuing a spawn statement when TrueLog Explorer is enabled causes Silk Test Classic to hang or crash.

Example

The following example demonstrates how you can use the spawn statement to create multiple threads. Note that UpdateDatabase could be either a test case or a function.

[-] multitestcase ()
	[ ] HMACHINE client1_handle 
	[ ] HMACHINE client2_handle 
	[ ] HMACHINE server_handle 
	[ ] server_handle = Connect ("server")
	[ ] client1_handle = Connect ("client1")
	[ ] client2_handle = Connect ("client2") 
	[ ] DoSomeSetup (server_handle)
	[ ] spawn 
	[ ] UpdateDatabase (client1_handle)
	[ ] spawn 
	[ ] UpdateDatabase (client2_handle)
	[ ] rendezvous 
	[ ] Disconnect (server_handle) 
	[ ] Disconnect (client1_handle) 
	[ ] Disconnect (client2_handle)