how to run a javascript function asynchronously, without using setTimeout?
问题 its a server side Javascript (rhino engine), so setTimeout is not available. how to run a function asynchronously? 回答1: Have a look at the Multithreaded Script Execution example on the Rhino Examples page. Basically, JavaScript does not support threading directly, but you may be able to use a Java thread to achieve what you are looking for. 回答2: You can use java.util.Timer and java.util.TimerTask to roll your own set/clear Timeout and set/clear Interval functions: var setTimeout, clearTimeout