How to write a multi thread lua script or just let multiple scripts run together in a c++ program

Viewed 423

I have a c++ program.It contains several functions and works well in c++. Now I want to write a lua/c++ embedded program to help the tester(sometimes they do not know programming) test the functions.Not even consists different function permutation and combination,but also will use multi thread. For example,functions are called as ABCD,or BACD,DCBA... The sequences are uncertain.They need to adjust the params for every functions. And sometimes,two or more threads are needed to run at the same time.

Every lua script contains a endless loop and I want to run them at the same time.How could I do?

lua_State *L;
L = luaL_newstate();
luaopen_base(L);
luaL_setfuncs(L, mylib, 0);
luaL_dofile(L, "test1.lua");  // start thread1
luaL_dofile(L, "test2.lua");  // start thread2

return 0;
0 Answers
Related