   [java] Preventing the same action from being performed too quickly?
  I've been using the LuaJava library to add lua scripting to my game. I had to add my own multithreading support: when a new script needs to be created, LuaMain.createScriptThread(source) is called, which creates a new thread of a ScriptThread object. The constructor of the ScriptThread creates a new LuaState (part of the library), the run() method executes the script.The library is kind of buggy though, if I create too many script threads quickly (rapidly clicking the Execute Command button, for example) then Java crashes (it is a native library.) I don't know C so I can't debug the library, but instead I want to limit the rate that new scripts can be made--if they are created too quickly, the extra ones are put in a queue and created one at a time. Simultaneous running is fine, but creating two threads at once is bad.How would I do this?Thanks.   
  Have you tried telling the thread to sleep after initial script execution?   