the "t.join" synchronizes the spawned thread with the main thread
(rendez-vous)
--------------
t = Thread.new do
    puts "==>START THREAD"
    sleep 15
    puts "==>END THREAD"
end

arr = [1,2,3,4,5,6,7,8,9,10]
for item in arr
    puts "==> Show item: " + item.to_s
    sleep 1
end

t.join # <- move it here, otherwise the spawned thread is bein
termintaed with the main program...
-------------



On 5 Dez., 00:06, Paulo Coutinho <pa...@prsolucoes.com> wrote:
> I have make a sample, to test ruby thread, but no success. it run like a
> single thread.
>
> t = Thread.new() do |n|
>     puts "==>START THREAD"
>     sleep 15
>     puts "==>END THREAD"
> end
>
> t.join
>
> arr = [1,2,3,4,5,6,7,8,9,10]
> for item in arr
>     puts "==> Show item: " + item.to_s
>     sleep 1
> end
>
> Thx.
>
> 2009/12/4 Paulo Coutinho <pa...@prsolucoes.com>
>
>
>
>
>
> > I have a game server to my game in flash, but the server is in pure java,
> > using sockets.
>
> > So i want port it do jruby, because i think its very fast and easy to make
> > database operations and all ruby facilities.
>
> > What you think about it? Is a good solution?
>
> > 2009/12/4 Clemens <clemens.w...@helbling.ch>
>
> > Ruby has a Thread class.
> >> t = Thread.new do
> >>  ...
> >> end
>
> >> Depending on whether you want to act as a socket server you can make
> >> use of ruby's TCPServer, or if you want to connect to a (socket)
> >> server there's the TCPSocket class.
>
> >> What exactly do you want to do, what is your use case? Why do you need
> >> (long-living?) threads (per session or, even worse, "click"?)?
> >> Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README) or
> >> delayed_job (http://github.com/tobi/delayed_job) suffice?
>
> >> Hope this helps
>
> >> On 3 Dez., 07:56, Paulo Coutinho <pa...@prsolucoes.com> wrote:
> >> > Hi,
>
> >> > How to make a socket to listen a port and make it multi-thread (one
> >> thread
> >> > per client connection) with JRUBY ?
>
> >> > Anyone have examples or can give me a code?
>
> >> > --
> >> > Atenciosamente,
> >> > Paulo Coutinho.
> >> > Blog:www.prsolucoes.com/blog
> >> > Site:www.prsolucoes.com
> >> > Msn:  pa...@prsolucoes.com
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Ruby on Rails: Talk" group.
> >> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscrib...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > Atenciosamente,
> > Paulo Coutinho.
> > Blog:www.prsolucoes.com/blog
> > Site:www.prsolucoes.com
> > Msn:  pa...@prsolucoes.com
>
> --
> Atenciosamente,
> Paulo Coutinho.
> Blog:www.prsolucoes.com/blog
> Site:www.prsolucoes.com
> Msn:  pa...@prsolucoes.com- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to