Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Thread::Queue.new

Thread::Queue.new → empty_queue
Thread::Queue.new(enumerable) → queue

Creates a new queue instance, optionally using the contents of an enumerable for its initial state.

Example:

Example
q = Thread::Queue.new
#=> #<Thread::Queue:0x00007ff7501110d0>
q.empty?
#=> true

q = Thread::Queue.new([1, 2, 3])
#=> #<Thread::Queue:0x00007ff7500ec500>
q.empty?
#=> false
q.pop
#=> 1

Ruby version changes

  1. 3.1
See also #<< #clear also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1