Is there a way we can do this, because i'd like to do something like,
::print(1);
local f1 = (function() {
for (local i = 0; i < 1000000; i++) {
::print(2);
}
});
local f2 = (function() {
::print("Hello world!");
});
local t1 = ::newthread(f1);
local t2 = ::newthread(f2);
t1.call(); // this blocks the rest of the script from running
// the next call should be possible for running parallel and non-blocking, but it doesnt
t2.call(); // executed only after t1 finishes, which takes a few seconds
A thread will runt until suspend() is called. Squirrel threads are not "OS Threads" are cooperative threads and they must be suspended and resumed explicitly(with suspend and thread.wakeup()).
Is there a way we can do this, because i'd like to do something like,