🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.ruby
2 messages
2 total messages Started by pawel Mon, 19 Oct 2009 22:07
wątki same się kończą
#1279
Author: pawel
Date: Mon, 19 Oct 2009 22:07
19 lines
1591 bytes
Czemu w poniższym kodzie zamiast dużej ilości 'lala' na wyjściu nie
dostaje nic, a program od razu się kończy?
Przecież tam powinien chodzić nieskończony wątek i dawać jakis output
cały czas.
class Bar
  def initialize

  end
  def foo
     Thread.new do
      while true
        puts "lala\n"
      end
    end
  end
end

b=Bar.new
b.foo
Re: wątki same się kończą
#1280
Author: luckboy
Date: Tue, 20 Oct 2009 09:03
22 lines
1431 bytes
pawel pisze:
> Czemu w poniższym kodzie zamiast dużej ilości 'lala' na wyjściu nie
> dostaje nic, a program od razu się kończy?
> Przecież tam powinien chodzić nieskończony wątek i dawać jakis output
> cały czas.
> class Bar
>   def initialize
> 
>   end
>   def foo
>      Thread.new do
>       while true
>         puts "lala\n"
>       end
>     end
>   end
> end
> 
> b=Bar.new
> b.foo

Po prostu musisz poczekać na wątek z za pomocą metody join.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads