Ruby | Thread group() function
Thread#group() : group() is a Thread class method which returns the ThreadGroup which contains the given thread, or returns nil if thread is not a member of any group.
Syntax: Thread.group()
Parameter: Thread values
Return: the ThreadGroup which contains the given thread
nil – if thread is not a member of any group.
Example #1 :
# Ruby code for Thread.group() method # declaring Thread a = Thread.new { print "a"; Thread.stop; print "c" } # group form puts "Thread a group() form : #{a.group()}\n\n" |
Output :
Thread a group() form : #
Example #2 :
# Ruby code for Thread.group() method # declaring Thread a = Thread.new { puts "HI! I am learning to code"} # group form puts "Thread a group() form : #{a.group()}\n\n" |
Output :
Thread a group() form : #
Note :
The ThreadGroup object generated in the output depends on the system and pointer value. So, it may vary each time the code is run.
Recommended Posts:
- Ruby | Thread alive? function
- Ruby | Thread exit() function
- Ruby | Thread add_trace_func function
- Ruby | Thread kill() function
- Ruby | Thread backtrace function
- Ruby | Thread backtrace_locations() function
- Ruby | Thread terminate() function
- Ruby | Thread abort_on_exception= function
- Ruby | Thread abort_on_exception function
- Ruby | Thread Life Cycle & Its States
- Ruby | Thread Class-Public Class Methods
- Ruby | at() function
- Ruby | pop() function
- Ruby | Set add? function
- Ruby | BigDecimal zero?() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



