Yesterday I made this thread implementation in ActionScript 2. Needed it for a multiple file upload app.</p>
Example 1
var t:Thread = new Thread();
t.run = function(arg) {
trace("Wehoo! I'm from the thread");
}
t.start();
Example 2
for(var i:Number = 0; i<5; i++)
{
var delay:Number = Math.round(Math.random()*1000);
var t:Thread = new Thread();
t.run = function(name) {
trace("Wehoo! I'm from " + name);
}
t.start("Thread " + i, delay);
}
Example 3
class MyStuff implements Runnable {
public function run(a):Void {
// do stuff...
}
}
...
var myStuff:MyStuff = new MyStuff();
var t:Thread = new Thread(myStuff);
t.start();