GODPAPER | All Packages | All Classes | Index | Frames No Frames |
ThreadUtil

Package | org.generalrelativity.thread.util
Class | public class ThreadUtil
Inheritance | ThreadUtil Object

Offers a simple API for thread creation

See also

GreenThread

Public Methods

| Method | Defined By
--- | --- | ---
|  | open(processes:Vector.<IRunnable>, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false, callback:Function = null):GreenThread [static] Opens and returns a GreenThread. | ThreadUtil
|  | openSingle(process:IRunnable, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false, callback:Function = null):GreenThread [static] Opens a single process in its own GreenThread This is just a helpful utility to get around verbose Vector instantiation. | ThreadUtil

Method Detail

open | () | method

`public static function open(processes:Vector.<IRunnable>, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false, callback:Function = null):GreenThread`

Opens and returns a GreenThread.

Note that the first 4 arguments match those in a GreenThread's constructor. If a callback is supplied, it (Function) is called when the thread has completed. For other handlable Events, see `GreenThread`.

Parameters

| `processes:Vector.<IRunnable>`
| `hertz:int`
| `share:Number` (default = `0.5`)``
| `isDiagnostic:Boolean` (default = `false`)``
| `callback:Function` (default = `null`)``

Returns

| `GreenThread`

See also

openSingle
GreenThread

openSingle | () | method |

`public static function openSingle(process:IRunnable, hertz:int, share:Number = 0.5, isDiagnostic:Boolean = false, callback:Function = null):GreenThread`

Opens a single process in its own `GreenThread`

This is just a helpful utility to get around verbose Vector instantiation.

Parameters

| `process:IRunnable`
| `hertz:int`
| `share:Number` (default = `0.5`)``
| `isDiagnostic:Boolean` (default = `false`)``
| `callback:Function` (default = `null`)``

Returns

| `GreenThread`

See also

open
GreenThread
Example
The following opens a single process in a `GreenThread`

                     public function openThread() : void
                     {

                         //create process
                         var process:IRunnable = new SomeProcess();

                         //creates and opens the thread, requesting onThreadComplete to be called on completion
                         ThreadUtil.openSingle( process, stage.frameRate, 0.5, false, onThreadComplete );

                     }

                     public function onThreadComplete() : void
                     {
                         //process done!
                     }

Thu Jan 16 2014, 01:11 PM +08:00