org.jruby
Class RubyThread
java.lang.Object
org.jruby.RubyObject
org.jruby.RubyThread
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
public class RubyThread
- 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
).
Note: For CVS history, see ThreadClass.java.
- See Also:
- Serialized Form
Field Summary |
java.lang.Object |
killLock
|
java.util.concurrent.locks.ReentrantLock |
lock
|
java.lang.Object |
stopLock
|
Fields inherited from class org.jruby.RubyObject |
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, metaClassName, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold |
Method Summary |
static IRubyObject |
abort_on_exception_set_x(IRubyObject recv,
IRubyObject value)
|
IRubyObject |
abort_on_exception_set(IRubyObject val)
|
static RubyBoolean |
abort_on_exception_x(IRubyObject recv)
Returns the status of the global ``abort on exception'' condition. |
RubyBoolean |
abort_on_exception()
|
static RubyThread |
adopt(IRubyObject recv,
java.lang.Thread t)
|
void |
afterBlockingCall()
|
RubyBoolean |
alive_p()
|
void |
beforeBlockingCall()
|
void |
cleanTerminate(IRubyObject result)
|
static RubyClass |
createThreadClass(Ruby runtime)
|
static IRubyObject |
critical_set(IRubyObject receiver,
IRubyObject value)
|
static IRubyObject |
critical(IRubyObject receiver)
|
static RubyThread |
current(IRubyObject recv)
|
void |
dispose()
Dispose of the current thread by removing it from its parent ThreadGroup. |
void |
exceptionRaised(RaiseException exception)
|
IRubyObject |
group()
|
IRubyObject |
initialize(IRubyObject[] args,
Block block)
|
IRubyObject |
inspect()
rb_obj_inspect
call-seq:
obj.inspect => string
Returns a string containing a human-readable representation of
obj. |
void |
interrupt()
|
IRubyObject |
join(IRubyObject[] args)
|
RubyBoolean |
key_p(IRubyObject key)
|
RubyArray |
keys()
|
IRubyObject |
kill_bang()
|
IRubyObject |
kill()
|
static IRubyObject |
kill(IRubyObject receiver,
IRubyObject rubyThread,
Block block)
|
static RubyArray |
list(IRubyObject recv)
|
static RubyThread |
main(IRubyObject recv)
|
static RubyThread |
mainThread(IRubyObject receiver)
|
static IRubyObject |
newInstance(IRubyObject recv,
IRubyObject[] args,
Block block)
Thread.new |
IRubyObject |
op_aref(IRubyObject key)
|
IRubyObject |
op_aset(IRubyObject key,
IRubyObject value)
|
static IRubyObject |
pass(IRubyObject recv)
|
void |
pollThreadEvents()
|
void |
pollThreadEvents(ThreadContext context)
|
IRubyObject |
priority_set(IRubyObject priority)
|
RubyFixnum |
priority()
|
IRubyObject |
raise(IRubyObject[] args,
Block block)
|
IRubyObject |
run()
|
static IRubyObject |
s_exit(IRubyObject receiver,
Block block)
|
IRubyObject |
safe_level()
|
boolean |
selectForAccept(RubyIO io)
|
void |
sleep(long millis)
|
static RubyThread |
start(IRubyObject recv,
IRubyObject[] args,
Block block)
Basically the same as Thread.new . |
IRubyObject |
status()
|
RubyBoolean |
stop_p()
|
static IRubyObject |
stop(IRubyObject receiver)
|
IRubyObject |
value()
|
RubyThread |
wakeup()
|
Methods inherited from class org.jruby.RubyObject |
addFinalizer, anyToString, asJavaString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, eqlInternal, equal_p, equalInternal, equals, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getNativeTypeIndex, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hash, hashCode, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize_copy, initialize, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, makeMetaClass, method, methods, nil_p, op_eqq, op_equal, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, singleton_methods, specificEval, syncVariables, taint, tainted_p, testFrozen, to_a, to_s, toString, type_deprecated, type, untaint, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetMap, variableTableGetMap, variableTableGetSize, variableTableGetTable, variableTableReadLocked, variableTableRehash, variableTableRemove, variableTableStore, variableTableSync |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
stopLock
public java.lang.Object stopLock
killLock
public java.lang.Object killLock
lock
public final java.util.concurrent.locks.ReentrantLock lock
RubyThread
protected RubyThread(Ruby runtime,
RubyClass type)
dispose
public void dispose()
- Dispose of the current thread by removing it from its parent ThreadGroup.
createThreadClass
public static RubyClass createThreadClass(Ruby runtime)
newInstance
public static IRubyObject newInstance(IRubyObject recv,
IRubyObject[] args,
Block block)
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 RubyThread start(IRubyObject recv,
IRubyObject[] args,
Block block)
- 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.
adopt
public static RubyThread adopt(IRubyObject recv,
java.lang.Thread t)
initialize
public IRubyObject initialize(IRubyObject[] args,
Block block)
cleanTerminate
public void cleanTerminate(IRubyObject result)
pollThreadEvents
public void pollThreadEvents()
pollThreadEvents
public void pollThreadEvents(ThreadContext context)
abort_on_exception_x
public static RubyBoolean abort_on_exception_x(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_x
public static IRubyObject abort_on_exception_set_x(IRubyObject recv,
IRubyObject value)
current
public static RubyThread current(IRubyObject recv)
main
public static RubyThread main(IRubyObject recv)
pass
public static IRubyObject pass(IRubyObject recv)
list
public static RubyArray list(IRubyObject recv)
op_aref
public IRubyObject op_aref(IRubyObject key)
op_aset
public IRubyObject op_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)
alive_p
public RubyBoolean alive_p()
join
public IRubyObject join(IRubyObject[] args)
value
public IRubyObject value()
group
public IRubyObject group()
inspect
public IRubyObject inspect()
- Description copied from class:
RubyObject
- rb_obj_inspect
call-seq:
obj.inspect => string
Returns a string containing a human-readable representation of
obj. If not overridden, uses the
to_s
method to
generate the string.
[ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"
- Specified by:
inspect
in interface IRubyObject
- Overrides:
inspect
in class RubyObject
- Returns:
- String
key_p
public RubyBoolean key_p(IRubyObject key)
keys
public RubyArray keys()
critical_set
public static IRubyObject critical_set(IRubyObject receiver,
IRubyObject value)
critical
public static IRubyObject critical(IRubyObject receiver)
stop
public static IRubyObject stop(IRubyObject receiver)
kill
public static IRubyObject kill(IRubyObject receiver,
IRubyObject rubyThread,
Block block)
s_exit
public static IRubyObject s_exit(IRubyObject receiver,
Block block)
stop_p
public RubyBoolean stop_p()
wakeup
public RubyThread wakeup()
priority
public RubyFixnum priority()
priority_set
public IRubyObject priority_set(IRubyObject priority)
raise
public IRubyObject raise(IRubyObject[] args,
Block block)
run
public IRubyObject run()
sleep
public void sleep(long millis)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
status
public IRubyObject status()
kill
public IRubyObject kill()
kill_bang
public IRubyObject kill_bang()
safe_level
public IRubyObject safe_level()
exceptionRaised
public void exceptionRaised(RaiseException exception)
mainThread
public static RubyThread mainThread(IRubyObject receiver)
selectForAccept
public boolean selectForAccept(RubyIO io)
interrupt
public void interrupt()
beforeBlockingCall
public void beforeBlockingCall()
afterBlockingCall
public void afterBlockingCall()
Copyright © 2002-2007 JRuby Team. All Rights Reserved.