Bird
0
0

What does Thread.new do in Ruby?

easy📝 Conceptual Q11 of 15
Ruby - Concurrent Programming
What does Thread.new do in Ruby?
AIt creates a new thread to run code concurrently.
BIt pauses the current thread until another finishes.
CIt terminates all running threads immediately.
DIt converts a method into a thread-safe version.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of Thread.new

    Thread.new starts a new thread that runs the code inside its block concurrently with the main program.
  2. Step 2: Compare options with the behavior

    Only It creates a new thread to run code concurrently. correctly describes creating a new thread to run code at the same time as other threads.
  3. Final Answer:

    It creates a new thread to run code concurrently. -> Option A
  4. Quick Check:

    Thread.new = create thread [OK]
Quick Trick: Remember: Thread.new starts a new thread block [OK]
Common Mistakes:
  • Confusing thread creation with thread termination
  • Thinking Thread.new pauses threads
  • Assuming Thread.new modifies methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes