# Problem on enpanding array?

**URL:** <https://www.ruby-forum.com/t/problem-on-enpanding-array/102368>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/problem-on-enpanding-array/102368 "2006-08-15T14:16:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias\_Ludwig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@Matthias\_Ludwig](https://www.ruby-forum.com/u/Matthias_Ludwig)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/problem-on-enpanding-array/102368/1 "2006-08-15T14:16:17Z")

</div>

Hi,

i wrote a little class for thread-pools, but there is a problem  
expanding args on a method-call.

def new\_thread(\*args, &action)

# wait until a slot in the pool is free

…

# start thread

threads \<\< Thread.new { action.call(\*args) }  
end

In the block (which is the “work to do in the thread”) the args  
should be available with |arg1, arg2, …|, but the aren’t. They  
are still in one array (args).

Any ideas what’s going wrong?

best regards,  
Matthias

---

<div class="post-metadata">

**Author:** ![Matthias\_Ludwig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@Matthias\_Ludwig](https://www.ruby-forum.com/u/Matthias_Ludwig)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/problem-on-enpanding-array/102368/2 "2006-08-15T14:16:49Z")

</div>

On Fri, 11 Aug 2006 17:32:27 +0900, Matthias Ludwig wrote:

> threads \<\< Thread.new { action.call(\*args) }  
> Attachment not shown: MIME type application/pgp-signature  
> Works for me:

$threads=[]  
def new\_thread(\*args, &action)

# start thread

$threads \<\< Thread.new { action.call(\*args) }  
end

new\_thread(7,“Hello”) {|n,m| n.times{sleep 1; puts m}}

sleep 10
