Ruby | Thread group() function
Last Updated :
06 Dec, 2019
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 :
a = Thread . new { print "a" ; Thread .stop; print "c" }
puts "Thread a group() form : #{a.group()}\n\n"
|
Output :
Thread a group() form : #
Example #2 :
a = Thread . new { puts "HI! I am learning to code" }
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.
Share your thoughts in the comments
Please Login to comment...