I was searching the web yesterday for this and didn’t really find a simple way of doing this and suddenly, I remembered something.
It’s extremely simple, someone could build on it with all sorts of features but for now, here is an example:
http://images.code-head.com/code/javascript/js-threads.html
As you can see there are two counters, one is counting up and the other down simultaneously.
Here is the start_thread function:
function thread_start(callback) { setTimeout(callback, 1); return true; }
The trick is that setTimeout *does not* block the execution
I hope this helps someone
Hamid Alipour is a partner in Codehead, LLP with his wife, Tess. Hamid speaks 12 markup and programming languages [Yes, 12: PHP, CSS, Ajax, JavaScript, HTML/XHTML, Java, Python, C/C++, ASP, Visual Basic, Scheme and Action Script]; has a penchant for solving the unsolvable; an affinity for clean, hand-written code and is a Zend Certified 