El Martes, 20 de Octubre de 2009, pawel escribi=F3:
> Why this simple program give no output, and terminates immidiatly
> after its launched? There should be thread running and giving lots of
> 'lala', am I right?
> class Bar
>   def initialize
>=20
>   end
>   def foo
>      Thread.new do
>       while true
>         puts "lala\n"
>       end
>     end
>   end
> end
>=20
> b=3DBar.new
> b.foo
>=20


When you create a thread, the main threads continues. In you case the main=
=20
thread terminates after calling "Thread.new" so the program exists.

If you want to *wait* all the created threads to finish their work, then yo=
u=20
must "join" them:

  my_thread =3D Thread.new do .... end
  do other stuff in main thread
  my_thread.join



=2D-=20
I=F1aki Baz Castillo <ibc / aliax.net>