org.jruby
Class ThreadClass

java.lang.Object
  extended byorg.jruby.RubyObject
      extended byorg.jruby.ThreadClass
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject

public class ThreadClass
extends RubyObject

Implementation of Ruby's Thread class. Each Ruby thread is mapped to an underlying Java Virtual Machine thread.

Thread encapsulates the behavior of a thread of execution, including the main thread of the Ruby script. In the descriptions that follow, the parameter aSymbol refers to a symbol, which is either a quoted string or a Symbol (such as :name).

Version:
$Revision: 1.10 $
Author:
Jason Voegele (jason@jvoegele.com)

Field Summary
 
Fields inherited from class org.jruby.RubyObject
runtime
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Method Summary
 IRubyObject abort_on_exception_set(IRubyObject val)
           
static IRubyObject abort_on_exception_set(IRubyObject recv, IRubyObject value)
           
 RubyBoolean abort_on_exception()
           
static RubyBoolean abort_on_exception(IRubyObject recv)
          Returns the status of the global ``abort on exception'' condition.
 IRubyObject aref(IRubyObject key)
           
 IRubyObject aset(IRubyObject key, IRubyObject value)
           
static RubyClass createThreadClass(Ruby ruby)
           
static ThreadClass current(IRubyObject recv)
           
 RubyBoolean has_key(IRubyObject key)
           
 RubyBoolean is_alive()
           
 ThreadClass join()
           
static RubyArray list(IRubyObject recv)
           
static ThreadClass mainThread(IRubyObject receiver)
           
static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args)
          Thread.new
static IRubyObject pass(IRubyObject recv)
           
 void pollThreadEvents()
           
 IRubyObject priority_set(IRubyObject priority)
           
 RubyFixnum priority()
           
 IRubyObject raise(IRubyObject exc)
           
static ThreadClass start(IRubyObject recv, IRubyObject[] args)
          Basically the same as Thread.new .
 IRubyObject status()
           
 
Methods inherited from class org.jruby.RubyObject
argCount, asSymbol, callbackFactory, callInit, callMethod, callMethod, callMethod, checkSafeString, convertToString, convertToType, convertType, createObjectClass, defineSingletonMethod, display, dup, equal, equals, eval, eval, evalUnder, extend, extendObject, freeze, frozen, getInstanceVariable, getInstanceVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getType, hash, hashCode, hasInstanceVariable, id, infectBy, inspect, instance_eval, instance_of, instance_variables, instanceVariableNames, isFalse, isFrozen, isKindOf, isNil, isTaint, isTrue, kind_of, makeMetaClass, marshalTo, method_missing, method, methods, nilObject, private_methods, protected_methods, rbClone, removeInstanceVariable, respond_to, respondsTo, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, setupClone, singleton_methods, singletonMethodsAllowed, specificEval, taint, tainted, to_a, to_s, toString, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createThreadClass

public static RubyClass createThreadClass(Ruby ruby)

newInstance

public static IRubyObject newInstance(IRubyObject recv,
                                      IRubyObject[] args)
Thread.new

Thread.new( [ arg ]* ) {| args | block } -> aThread

Creates a new thread to execute the instructions given in block, and begins running it. Any arguments passed to Thread.new are passed into the block.

 x = Thread.new { sleep .1; print "x"; print "y"; print "z" }
 a = Thread.new { print "a"; print "b"; sleep .2; print "c" }
 x.join # Let the threads finish before
 a.join # main thread exits...
 
produces: abxyzc


start

public static ThreadClass start(IRubyObject recv,
                                IRubyObject[] args)
Basically the same as Thread.new . However, if class Thread is subclassed, then calling start in that subclass will not invoke the subclass's initialize method.


pollThreadEvents

public void pollThreadEvents()

abort_on_exception

public static RubyBoolean abort_on_exception(IRubyObject recv)
Returns the status of the global ``abort on exception'' condition. The default is false. When set to true, will cause all threads to abort (the process will exit(0)) if an exception is raised in any thread. See also Thread.abort_on_exception= .


abort_on_exception_set

public static IRubyObject abort_on_exception_set(IRubyObject recv,
                                                 IRubyObject value)

current

public static ThreadClass current(IRubyObject recv)

pass

public static IRubyObject pass(IRubyObject recv)

list

public static RubyArray list(IRubyObject recv)

aref

public IRubyObject aref(IRubyObject key)

aset

public IRubyObject aset(IRubyObject key,
                        IRubyObject value)

abort_on_exception

public RubyBoolean abort_on_exception()

abort_on_exception_set

public IRubyObject abort_on_exception_set(IRubyObject val)

is_alive

public RubyBoolean is_alive()

join

public ThreadClass join()

has_key

public RubyBoolean has_key(IRubyObject key)

priority

public RubyFixnum priority()

priority_set

public IRubyObject priority_set(IRubyObject priority)

raise

public IRubyObject raise(IRubyObject exc)

status

public IRubyObject status()

mainThread

public static ThreadClass mainThread(IRubyObject receiver)


Copyright © 2002 Jan Arne Petersen. All Rights Reserved.