up: THREAD     index Zimbu documentation

CLASS T.thread EXTENDS THREAD.ThreadBase @public

summary

     

The builtin type thread.

A thread that will execute a method.

Example: run myProc() in a thread:

 thread t = T.thread.NEW(myProc).start()
 t.wait()

Example: subclass

 CLASS MyThread EXTENDS thread
  PROC $body() @replace
    int count
    WHILE TRUE
      IO.print(count)
      ++count
      TIME.sleep(500'000)
    }
  }
 }

 MyThread t = NEW(doSomething)
 t.start()
 TIME.sleepSec(3)
 t.kill()

NEW(proc) @public  Create a new thread that will execute proc.
NEW(func) @public  Create a new thread that will execute func.
$body() @public  The default method to execute: call the method specified at creation or with setProc().
$setProc(proc) @public  Set the method to be invoked by the default body() method.
 
Inherited from THREAD.ThreadBase:
string  $name @public  optional name, NIL when not set
THREAD.State  $state @public  state of the thread
Type  $type @public  type of thread
int  $ctxLen @file 
 
NEW() @public  Create a new thread.
$setName(name) ThreadBase @file  Set the name of the thread.
$start() ThreadBase @public  Start executing the thread.
$wait() @public  Wait in the current thread for the thread of this object to finish.
$kill() @public  Kill the thread, stop its execution.
$remove() @public  Not Implemented Yet
 

members (alphabetically)

     

PROC NEW(proc<> proc) @public

     

Create a new thread that will execute proc.

PROC NEW(func< => status> func) @public

     

Create a new thread that will execute func.

The return value is ignored.

PROC $body() @default @public

     

The default method to execute: call the method specified at creation or with setProc().

Replace this method in a subclass to have the thread do something else.

PROC $setProc(proc<> proc) @public

     

Set the method to be invoked by the default body() method.

TODO: return the object.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0