Ruby Thread Functions
EditRocket provides the following information on Thread functions in the Ruby source code builder.
abort_on_exception= - When set to true, all threads will abort if an exception is raised. Returns the new state.
abort_on_exception= - When set to true, all threads will abort if an exception is raised. Returns the new state.
abort_on_exception - Returns the status of the global ``abort on exception'' condition. The default is false. When set to true, or if the global $DEBUG flag is true (perhaps because the command line option -d was specified) all threads will abort (the process will exit(0)) if an exception is raised in any thread. See also Thread::abort_on_exception=.
abort_on_exception - Returns the status of the global ``abort on exception'' condition. The default is false. When set to true, or if the global $DEBUG flag is true (perhaps because the command line option -d was specified) all threads will abort (the process will exit(0)) if an exception is raised in any thread. See also Thread::abort_on_exception=.
alive? - Returns true if thr is running or sleeping.
critical= - "Sets the status of the global ``thread critical'' condition and returns it. When set to true, prohibits scheduling of any existing thread. Does not block new threads from being created and run. Certain thread operations (such as stopping or killing a thread, sleeping in the current thread, and raising an exception) may cause a thread to be scheduled even when in a critical section. Thread::critical is not intended for daily use: it is primarily there to support folks writing threading libraries."
critical - Returns the status of the global ``thread critical'' condition.
current - Returns the currently executing thread.
exclusive() - Wraps a block in Thread.critical, restoring the original value upon exit from the critical section.
exit! - Terminates thr without calling ensure clauses and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process.
exit - Terminates the currently running thread and schedules another thread to be run. If this thread is already marked to be killed, exit returns the Thread. If this is the main thread, or the last thread, exit the process.
exit - Terminates the currently running thread and schedules another thread to be run. If this thread is already marked to be killed, exit returns the Thread. If this is the main thread, or the last thread, exit the process.
fork([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.
group - Returns the ThreadGroup which contains thr, or nil if the thread is not a member of any group.
inspect - Dump the name, id, and status of thr to a string.
join(limit) - The calling thread will suspend execution and run thr. Does not return until thr exits or until limit seconds have passed. If the time limit expires, nil will be returned, otherwise thr is returned.
key?(sym) - Returns true if the given string (or symbol) exists as a thread-local variable.
keys - Returns an an array of the names of the thread-local variables (as Symbols).
kill! - Terminates thr without calling ensure clauses and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process.
kill(thread) - Causes the given thread to exit (see Thread::exit).
kill(thread) - Causes the given thread to exit (see Thread::exit).
list - Returns an array of Thread objects for all threads that are either runnable or stopped.
main - Returns the main thread for the process.
new([arg]*) - Creates and runs a new thread to execute the instructions given in block. Any arguments passed to Thread::new are passed into the block.
pass - Invokes the thread scheduler to pass execution to another thread.
priority= - Sets the priority of thr to integer. Higher-priority threads will run before lower-priority threads.
priority - Returns the priority of thr. Default is inherited from the current thread which creating the new thread, or zero for the initial main thread; higher-priority threads will run before lower-priority threads.
raise(exception) - Raises an exception (see Kernel::raise) from thr. The caller does not have to be thr.
run - Wakes up thr, making it eligible for scheduling. If not in a critical section, then invokes the scheduler.
safe_level - Returns the safe level in effect for thr. Setting thread-local safe levels can help when implementing sandboxes which run insecure code.
start([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.
status - "Returns the status of thr: ``sleep'' if thr is sleeping or waiting on I/O, ``run'' if thr is executing, ``aborting'' if thr is aborting, false if thr terminated normally, and nil if thr terminated with an exception."
stop? - Returns true if thr is dead or sleeping.
stop - Stops execution of the current thread, putting it into a ``sleep'' state, and schedules execution of another thread. Resets the ``critical'' condition to false.
terminate! - Terminates thr without calling ensure clauses and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process.
terminate - Terminates thr and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process.
value - Waits for thr to complete (via Thread#join) and returns its value.
wakeup - Marks thr as eligible for scheduling (it may still remain blocked on I/O, however). Does not invoke the scheduler (see Thread#run).