Class Printer
class Printer
attr_reader :count
def initialize
@count=0
end
def print(caller)
puts "#{caller}: #{@count}"
@count+=1
end
end
p1=Printer.new
t2=Thread.new{100.times {p1.print("t2")}}
t1=Thread.new{100.times {p1.print("t1")}}
#t2=Thread.new{100.times {|i| puts "#{i} "}}
#t1=Thread.new{100.times{|i| puts i}}
t2.join
t1.join
attr_reader :count
def initialize
@count=0
end
def print(caller)
puts "#{caller}: #{@count}"
@count+=1
end
end
p1=Printer.new
t2=Thread.new{100.times {p1.print("t2")}}
t1=Thread.new{100.times {p1.print("t1")}}
#t2=Thread.new{100.times {|i| puts "#{i} "}}
#t1=Thread.new{100.times{|i| puts i}}
t2.join
t1.join