[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Phy Prabab

10/14/2008 8:39:00 AM

Hello,

So I am new to ruby and have a question about threads. Yes, I researched looking for an answer to my question without much luck. I am trying to create a bunch of threads that will run forever processing numerical information. I wrote a very simple example of what I thought would work:

threads = []

list = %w(aS, bS, cS, dS, eS, fS, gS, hS)

for space in list
threads << Thread.new(space) {|numericalSpace|
while 1
puts "#{thread.id}: #{numericalSpace}"
sleep 2
end
}
end

This does not work as I thought it would, that is it would spin off a bunch of threads and every two seconds I would get a thread print the simple line to the terminal.

So, what am I missing?

Thanks in advance!
Phy





4 Answers

Roger Pack

10/17/2008 6:12:00 AM

0

> This does not work as I thought it would, that is it would spin off a
> bunch of threads and every two seconds I would get a thread print the
> simple line to the terminal.
>
> So, what am I missing?

Try adding a Thread.abort_on_exception = true to the top.
Also note that if the "main" thread ever terminates then it kills all
other threads and ends the program
Cheers.
-=R
--
Posted via http://www.ruby-....

Jim Cone

7/29/2009 4:04:00 AM

0



For the problem module try...
copying the code and pasting it into Notepad.
delete the problem module.
insert a new module.
copy the Notepad code and paste it into the new module.
--
Jim Cone
Portland, Oregon USA




"Trefor" <Trefor@home.com>
wrote in message
Jim,
Thanks, but the code is not all in one module. I have it accross 30 modules
and forms. This particular module only has 700 lines of code in it.
--
Trefor


"Jim Cone" wrote:
> Patient: "It hurts when I do this."
> Doctor: "Don't do that."
>
> Prescription: VBE (toolbar) | Insert | Module
> (use as often as needed)
> --
> Jim Cone
> Portland, Oregon USA



> "Trefor" <Trefor@home.com>
> wrote in message
> I have some very large macro's/VBA 40K+ lines of code. It has been working
> fine and still runs ok, but if there is an error and it drops into the editor
> and I try and copy/paste a line of code I get "Out of Memory". If I type the
> line in from scratch it works fine. I rebooted the PC in case there was
> something weird happening, but it did not make any difference. I have finally
> reached the limits of Excel?? Any suggestions?
> --
> Trefor

Trefor

8/2/2009 4:40:00 PM

0

Jim,

Many thanks for your reply.

As mysteriously as this error came, it???s gone. I am not sure what???s going,
but I will be sure to try this if it comes back. Many thanks.

--
Trefor


"Jim Cone" wrote:

>
>
> For the problem module try...
> copying the code and pasting it into Notepad.
> delete the problem module.
> insert a new module.
> copy the Notepad code and paste it into the new module.
> --
> Jim Cone
> Portland, Oregon USA
>
>
>
>
> "Trefor" <Trefor@home.com>
> wrote in message
> Jim,
> Thanks, but the code is not all in one module. I have it accross 30 modules
> and forms. This particular module only has 700 lines of code in it.
> --
> Trefor
>
>
> "Jim Cone" wrote:
> > Patient: "It hurts when I do this."
> > Doctor: "Don't do that."
> >
> > Prescription: VBE (toolbar) | Insert | Module
> > (use as often as needed)
> > --
> > Jim Cone
> > Portland, Oregon USA
>
>
>
> > "Trefor" <Trefor@home.com>
> > wrote in message
> > I have some very large macro's/VBA 40K+ lines of code. It has been working
> > fine and still runs ok, but if there is an error and it drops into the editor
> > and I try and copy/paste a line of code I get "Out of Memory". If I type the
> > line in from scratch it works fine. I rebooted the PC in case there was
> > something weird happening, but it did not make any difference. I have finally
> > reached the limits of Excel?? Any suggestions?
> > --
> > Trefor
>
>

Trefor

8/2/2009 8:16:00 PM

0

Jim,

Many thanks for the reply.

As mysteriously as this error came, it???s gone. I am not sure what???s going,
but I will be sure to try this if it comes back. Many thanks.

--
Trefor


"Jim Cone" wrote:

>
>
> For the problem module try...
> copying the code and pasting it into Notepad.
> delete the problem module.
> insert a new module.
> copy the Notepad code and paste it into the new module.
> --
> Jim Cone
> Portland, Oregon USA
>
>
>
>
> "Trefor" <Trefor@home.com>
> wrote in message
> Jim,
> Thanks, but the code is not all in one module. I have it accross 30 modules
> and forms. This particular module only has 700 lines of code in it.
> --
> Trefor
>
>
> "Jim Cone" wrote:
> > Patient: "It hurts when I do this."
> > Doctor: "Don't do that."
> >
> > Prescription: VBE (toolbar) | Insert | Module
> > (use as often as needed)
> > --
> > Jim Cone
> > Portland, Oregon USA
>
>
>
> > "Trefor" <Trefor@home.com>
> > wrote in message
> > I have some very large macro's/VBA 40K+ lines of code. It has been working
> > fine and still runs ok, but if there is an error and it drops into the editor
> > and I try and copy/paste a line of code I get "Out of Memory". If I type the
> > line in from scratch it works fine. I rebooted the PC in case there was
> > something weird happening, but it did not make any difference. I have finally
> > reached the limits of Excel?? Any suggestions?
> > --
> > Trefor
>
>