Created
November 10, 2014 16:13
-
-
Save DanielVartanov/f1f3b6b5072f0b65c2c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'celluloid' | |
class Cell | |
include Celluloid | |
def expensive | |
puts "[Started]" | |
puts thread_count | |
10000000.times { 1 + 1 } | |
puts thread_count | |
puts "[Finished]" | |
end | |
def thread_count | |
Thread.list.select {|thread| thread.status == "run"}.count | |
end | |
end | |
cell = Cell.new | |
3.times.map do | |
cell.async.expensive | |
end | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment