repo.or.cz
/
jruby.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git]
/
bench
/
shootout
/
message.ruby
blob
e38981bd17375f4b184c98ec0bfac2435f760ab1
1
# The Computer Language Shootout
2
# http://shootout.alioth.debian.org/
3
#
4
# Contributed by Jesse Millikan
5
6
require
'thread'
7
8
N
=
ARGV
[
0
].
to_i
9
next_q
=
last_q
=
SizedQueue
.
new
(
1
)
10
11
500
.
times
{
12
q
=
SizedQueue
.
new
(
1
)
13
q2
=
next_q
14
Thread
.
new
{
15
i
=
N
16
while
i
>
0
17
q2
.
push
(
q
.
pop
+
1
)
18
i
-=
1
19
end
20
}
21
next_q
=
q
22
}
23
24
Thread
.
new
{
N
.
times
{
next_q
.
push
(
0
)}}
25
26
t
=
0
27
N
.
times
{
t
+=
last_q
.
pop
}
28
puts t
29