pastebin
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
pastebin
Follow @pastebin
create new paste
trending pastes
sign up
login
my settings
my profile
My Pastes
Public Pastes
Untitled
2 sec ago
Untitled
C | 4 sec ago
Untitled
4 sec ago
Using Ant to ensure a p...
5 sec ago
GirlsDoPorn Jenna Angel
5 sec ago
FOUND FACEBOOK PASSWORD
15 sec ago
Instanz
Perl | 10 sec ago
Filepremier Premium Acc...
11 sec ago
Layout Width
Share Pastebin
Mark Aufflick
By: a guest | Dec 11th, 2007 | Syntax:
None
| Size: 0.30 KB | Hits: 24 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
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}"
create new paste
|
create new version of this paste
RAW Paste Data
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}"