You could also exploit the module concept. The thread is implemented by spinning of a lua chunk in its own thread, thus not seing "the caller script".
If you collect your code in a module (or by using loadfile) you could load the chunk on demand either by using the require or loadfile primitives.
Consider the file case.lua placed in modules/case:
module (..., package.seeall)
function tryit(arg)
printf("in tryit, argument:%s",tostring(arg))
end
You may then call load and use the functions by this script:
function timeout()
runs = runs + 1
probe.log(0,"timeout #%d...",runs)
if runs % 3 == 0 then
probe.log(0,"time to spin of a thread...")
thread ()
require ("case")
case.tryit(args)
probe.log(0,"thread done...")
]],"arg1,arg2")
end
end
--
-- Main
--
runs = 0
probe.register("***","1.10","Nimsoft Corporation 2009")
probe.run()
probe.unregister()
Carstein