Skip to content

Instantly share code, notes, and snippets.

@jaydonnell
Created April 3, 2009 16:43
Show Gist options
  • Save jaydonnell/89827 to your computer and use it in GitHub Desktop.
Save jaydonnell/89827 to your computer and use it in GitHub Desktop.
require 'java'
module JavaLang
include_package "java.lang"
end
module JavaConncurrent
include_package "java.util.concurrent"
end
class BusyBee
include java.lang.Runnable
attr_accessor :q
def initialize
@q = JavaConncurrent::LinkedBlockingQueue.new
end
def run
puts 'woot'
end
end
def make_honey
processor_count = JavaLang::Runtime.getRuntime.availableProcessors
executor = JavaConncurrent::Executors.newFixedThreadPool(processor_count)
busy_bees = []
processor_count.times do |i|
bb = BusyBee.new
busy_bees << bb
executor.execute(bb)
end
executor.shutdown()
end
make_honey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment