Specifying the Target Machine Driven By a Thread

While the typical purpose for a thread is to direct test operations to a particular test machine, you have total flexibility as to which machine is being driven by a particular thread at any point in time. For example, in the code below, the spawn statement starts a thread for each machine in a predefined list of test machines. The SetMachine command directs the code in that thread to the Agent on the specified machine. But the ["server"] machine handle operator directs the code in the doThis function to the machine named server. The code following the doThis invocation continues to be sent to the sMachine specified in the SetMachine command.
for each smachine in lsMachine
  spawn // start thread for each sMachine
  SetMachine (sMachine)
  // ... code executed on sMachine
  ["server"]doThis() // code executed on "server" 
  // ...continue with code for sMachine
rendezvous

While the machine handle operator takes only a machine handle, 4Test implicitly casts the string form of the Agent machine’s name as a machine handle and so in the preceding example the machine name is effectively the same as a machine handle.