Runnables

at 2007-04-05 in Announcements by friebe (0 comments)

With RFC #0081 now implemented, the lang.Thread class now supports an additional way of implementing a thread: Besides subclassing the Thread class, you can now also pass any lang.Runnable object to its constructor.

Implementation by subclassing
(The conventional way)

  class ComputeThread extends Thread {
public
function run() {
// ...
}
}

$thread= new ComputeThread('computr1');
$thread->start();

Implementation by passing a Runnable
(Now also possible, using an anonymous class)
  $thread= new Thread(newinstance('lang.Runnable', array(), '{
public function run() {
// ...
}
}'
));
$thread->start();



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «Runnables».