# Threads in Ruby-Gnome?

**URL:** <https://www.ruby-forum.com/t/threads-in-ruby-gnome/242855>\
**Category:** Ruby-Gnome 2\
**Created:** [August 3, 2015, 1:00pm UTC](https://www.ruby-forum.com/t/threads-in-ruby-gnome/242855 "2015-08-03T13:00:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 3, 2015, 1:00pm UTC](https://www.ruby-forum.com/t/threads-in-ruby-gnome/242855/1 "2015-08-03T13:00:28Z")

</div>

Hello.

I have a simple widget.

One button to play a video file in mplayer.

When I click on it, it freezes the gtk app. The video is played fine but  
I don’t like that my program is frozen.

The code I use is this:

Thread.new {  
system MPLAYER+’ '+videofile  
}.join

Is there a way to not have the main app freeze? It unfreezes when the  
mplayer stops.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [August 4, 2015, 6:22pm UTC](https://www.ruby-forum.com/t/threads-in-ruby-gnome/242855/2 "2015-08-04T18:22:31Z")

</div>

Robert H. wrote in post #1177172:

> Thread.new {  
> system MPLAYER+’ '+videofile  
> }.join
> 
> Is there a way to not have the main app freeze? It unfreezes when the  
> mplayer stops.

suppress the .join  
your code in thread must not call gtk api.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [August 5, 2015, 1:20pm UTC](https://www.ruby-forum.com/t/threads-in-ruby-gnome/242855/3 "2015-08-05T13:20:43Z")

</div>

Regis d’Aubarede wrote in post #1177247:

> Robert H. wrote in post #1177172:
> 
> > Thread.new {  
> > system MPLAYER+’ '+videofile  
> > }.join
> > 
> > Is there a way to not have the main app freeze? It unfreezes when the  
> > mplayer stops.
> 
> suppress the .join  
> your code in thread must not call gtk api.

if user press 20 times the button, you will have 20 mplayers running…

you can test the number of thread running:  
if Thread.last.size==1  
Thread.new { system … }  
else  
message(“already running!”)  
end
