# Thread.new

**URL:** <https://www.ruby-forum.com/t/thread-new/214232>\
**Category:** wxRuby\
**Created:** [November 25, 2011, 9:05am UTC](https://www.ruby-forum.com/t/thread-new/214232 "2011-11-25T09:05:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 25, 2011, 9:05am UTC](https://www.ruby-forum.com/t/thread-new/214232/1 "2011-11-25T09:05:15Z")

</div>

This code runs fine (except you can’t mess with the window until the 10  
loops are finished). But if the comment mark is moved down to the  
10.times  
do so that it can run in a different thread, nothing below Thread.new do  
ever happens. Help! please. Thanks.

I’m running Ruby 1.9.3 and wxRuby 2.01.

def busy\_task  
# start task in a separate thread  
@text.append\_text “In busy\_task\n”

# Thread.new do

```
10.times do
  @text.append_text "In busy_task\n"
  @tasks += 1
  tasks = @tasks
  10.times do
    @text.append_text "running #{tasks} ... #{Time.new}\n"
    (1...1_00_000).inject :+
  end # do
  @text.append_text "Thread #{tasks} done\n"
end # do

```

end # busy\_task

–  
I have a right and a left brain, but there is nothing right in the left  
one  
and there is nothing left in the right one!

Homepage: [edsbog.com](http://edsbog.com) [http://edsbog.com](http://edsbog.com)

---

<div class="post-metadata">

**Author:** ![edconnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5e9695/32.png) [@edconnell](https://www.ruby-forum.com/u/edconnell)\
**Post date:** [November 26, 2011, 11:12am UTC](https://www.ruby-forum.com/t/thread-new/214232/2 "2011-11-26T11:12:53Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi Ed,

On 25.11.2011 08:14, Ed Connell wrote:

> This code runs fine (except you can’t mess with the window until  
> the 10 loops are finished). But if the comment mark is moved down  
> to the 10.times do so that it can run in a different thread,  
> nothing below Thread.new do ever happens. Help! please. Thanks.

wxRuby doesn’t like threads. Search the mailing list archives and  
you’ll find plenty of topics related to your problem. If you don’t  
need shared memory, I recommend you to look into processes.

Vale,  
Marvin  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.11 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iQEcBAEBAgAGBQJO0K0BAAoJELh1XLHFkqhaMEYH/07g2Qa505om9GNb4Y0ozSEn  
wByEaHu/C8VD9k9dOwzudoK4uP0FJyKPR39o6TFlD6kcYNy5nrJxiIitoHmuuw+P  
qXgS6qvcBub1vBHhx1WKiyb5SYaeBKDC/wXR7fdpjoql/f6vY9vOQ9iXFIMqmLMA  
h4cX6yzVNyfT88Ss4hia4L/ZccL6/6TnzneN/z1h49wdfAEdlR3gZ7vTlmUpuWt0  
i/4PnmBjXYL2NGEXnaRRgaXEpQB1q3Mrj4c8wC87WnM5M+1lp7N63swYW7BvZYOt  
zCu19Vs1zuLftA3iUOen9JAwa9qyKJeEW1WdbFCOLuGWXagSAc2gbcBM/TrSF1k=  
=x1sV  
-----END PGP SIGNATURE-----
