Thread#terminate() : terminate() is a Thread class method which is used to terminates the thread and schedules another thread to be run.
Syntax: Thread.terminate()
Parameter: Thread values
Return: terminates the thread
Example #1 :
a = Thread . new { print "a" ; Thread .stop; print "c" }
puts "Thread a terminate() form : #{a.terminate()}\n\n"
|
Output :
Thread a terminate() form : #
Example #2 :
a = Thread . new { puts "HI! I am learning to code" }
puts "Thread a terminate() form : #{a.terminate()}\n\n"
|
Output :
Thread a terminate() form : #
Note :
The thread object generated in the output depends on the system and pointer value. So, it may vary each time the code is run.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!