; This works very very well. Low CPU. All you have is the exe in memory for each thread.
; Send messages anyway you need. Try the iniwrite()/iniread(), regwrite()/regread, or fancy _NamedPipes.
#include <WinAPI.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <WinAPIShPath.au3>
#include <Misc.au3>
If $CmdLine[0] > 0 Then
If $CmdLine[1] = "MyFuncThread1" Then MyFuncThread1()
If $CmdLine[1] = "MyFuncThread2" Then MyFuncThread2()
If $CmdLine[1] = "MyFuncThread3" Then MyFuncThread3()
EndIf
If @Compiled Then
ShellExecute(@AutoItExe, "MyFuncThread1")
ShellExecute(@AutoItExe, "MyFuncThread2")
ShellExecute(@AutoItExe, "MyFuncThread3")
Else
ShellExecute(@ScriptName, "MyFuncThread1")
ShellExecute(@ScriptName, "MyFuncThread2")
ShellExecute(@ScriptName, "MyFuncThread3")
EndIf
;*** WARNING, if your thread returns without exiting - it will respawn. (Maybe you need that?)
Func MyFuncThread1()
_Singleton("MyFuncThread1", 0)
MsgBox(0, "", "Thread 1", 0)
Exit
EndFunc ;==>MyFuncThread1
Func MyFuncThread2()
_Singleton("MyFuncThread2", 0)
MsgBox(0, "", "Thread 2", 0)
Exit
EndFunc ;==>MyFuncThread2
Func MyFuncThread3()
_Singleton("MyFuncThread3", 0)
MsgBox(0, "", "Thread 3", 0)
Exit
EndFunc ;==>MyFuncThread3