Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Ruby Programming
Previous Page Home Next Page
class ThreadGroup
Parent: Object
Version: 1.6


new add list

ThreadGroup provides a means of keeping track of a number of threads as a group. A Thread can belong to only one ThreadGroup at a time; adding a thread to a new group will remove it from any previous group.

Newly created threads belong to the same group as the thread from which they were created.
Default Default thread group.

class methods
new -> thgrp

Returns a newly created ThreadGroup. The group is initially empty.

instance methods
add thgrp.add( aThread ) -> thgrp

Adds the given thread to this group, removing it from any other group to which it may have previously belonged.

puts "Initial group is #{ThreadGroup::Default.list}"
tg =
t1 = { sleep 10 }
t2 = { sleep 10 }
puts "t1 is #{t1}"
puts "t2 is #{t2}"
tg.add( t1 )
puts "Initial group now #{ThreadGroup::Default.list}"
puts "tg group now #{tg.list}"
Initial group is #<Thread:0x401be5c8>
t1 is #<Thread:0x401b5428>
t2 is #<Thread:0x401b53d8>
Initial group now #<Thread:0x401b53d8>#<Thread:0x401be5c8>
tg group now #<Thread:0x401b5428>

list thgrp.list -> anArray

Returns an array of all existing Thread objects that belong to this group.

ThreadGroup::Default.list [#<Thread:0x401be5c8 run>]

Ruby Programming
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire