Each of the statements within the parallel block creates a separate thread and these threads are executed in parallel until the end of the block. At the end of the parallel block, all running threads are held until the last thread completes its execution within the block. When all threads have completed within the block, the script continues.
parallel
statements
Variable | Description |
---|---|
statements | One or more statements to be executed in a new thread. |
Unlike the spawn command, the parallel statement does not require a rendezvous statement to synchronize threads.
You create, or "spawn," multiple threads using combinations of the 4Test statements parallel, spawn, rendezvous, and critical.
The parallel statement is shorthand for a series of spawn and rendezvous statements:
This Statement... | Is Equivalent To These Statements... |
---|---|
parallel statement-1 statement-2 |
spawn statement-1 spawn statement-2 rendezvous |
[-] main () [ ] HMACHINE client1_handle [ ] HMACHINE client2_handle [ ] HMACHINE server_handle [ ] server_handle = Connect ("server") [ ] client1_handle = Connect ("client1") [ ] client2_handle = Connect ("client2") [ ] DoSomeSetup (server_handle) [ ] [-] parallel [ ] UpdateDatabase (client1_handle) [ ] UpdateDatabase (client2_handle) [ ] [ ] Disconnect (server_handle) [ ] Disconnect (client1_handle) [ ] Disconnect (client2_handle)