Posted by Mark Aufflick on Tue 11 Dec 22:33
report abuse | download | new post
- class Counter
- attr_reader :count
- def initialize
- @count = 0;
- end
- def tick
- @count += 1
- end
- end
- c = Counter.new
- t1 = Thread.new { 10000.times { c.tick } }
- t2 = Thread.new { 10000.times { c.tick } }
- t1.join
- t2.join
- puts "#{c.count}"
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.