| 1 | #include <Constants.au3> |
|---|
| 2 | #include <array.au3> |
|---|
| 3 | Global $thread[4] |
|---|
| 4 | Global $line[4] |
|---|
| 5 | |
|---|
| 6 | $thread[1] = Run(@ScriptDir & "\stdout3.exe 1","",@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) |
|---|
| 7 | $thread[2] = Run(@ScriptDir & "\stdout3.exe 2","",@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) |
|---|
| 8 | $thread[3] = Run(@ScriptDir & "\stdout3.exe 3","",@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) |
|---|
| 9 | |
|---|
| 10 | Sleep(500) ; needed to make sure all threads are ready |
|---|
| 11 | |
|---|
| 12 | For $i=1 to 3 |
|---|
| 13 | $line[$i] = StdoutRead($thread[$i]) |
|---|
| 14 | if StringInStr($line[$i],"thread started") Then |
|---|
| 15 | ConsoleWrite($line[$i]) |
|---|
| 16 | StdinWrite($thread[$i],"start work") |
|---|
| 17 | Sleep(300) |
|---|
| 18 | EndIf |
|---|
| 19 | Next |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | ;~ ConsoleWrite(@CRLF & "------------ WAITING SOME TIME ------------" & @CRLF & @CRLF) |
|---|
| 23 | ;~ Sleep(15000) |
|---|
| 24 | |
|---|
| 25 | $done=0 |
|---|
| 26 | do |
|---|
| 27 | for $i = 1 to 3 |
|---|
| 28 | if $line[$i]=-1 then ContinueLoop |
|---|
| 29 | $line[$i] = StdoutRead($thread[$i]) |
|---|
| 30 | if $line[$i] <> "" Then ConsoleWrite($line[$i]) |
|---|
| 31 | if StringInStr($line[$i],"work done") Then |
|---|
| 32 | $done += 1 |
|---|
| 33 | $line[$i]=-1 |
|---|
| 34 | EndIf |
|---|
| 35 | Next |
|---|
| 36 | Until $done=3 |
|---|
| 37 | |
|---|
| 38 | For $i = 1 to 3 |
|---|
| 39 | StdinWrite($thread[$i],"exit") |
|---|
| 40 | $line[$i]="" |
|---|
| 41 | Next |
|---|
| 42 | |
|---|
| 43 | $done = 0 |
|---|
| 44 | do |
|---|
| 45 | For $i = 1 to 3 |
|---|
| 46 | if $line[$i]=-1 then ContinueLoop |
|---|
| 47 | $line[$i] = StdoutRead($thread[$i]) |
|---|
| 48 | if $line[$i] <> "" Then ConsoleWrite($line[$i]) |
|---|
| 49 | if StringInStr($line[$i],"exited by master") Then |
|---|
| 50 | $done += 1 |
|---|
| 51 | $line[$i]=-1 |
|---|
| 52 | EndIf |
|---|
| 53 | Next |
|---|
| 54 | Until $done =3 |
|---|