# Some threads are not starting

**URL:** <https://www.ruby-forum.com/t/some-threads-are-not-starting/124933>\
**Category:** Ruby\
**Created:** [January 3, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/some-threads-are-not-starting/124933 "2008-01-03T21:05:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 3, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/some-threads-are-not-starting/124933/1 "2008-01-03T21:05:30Z")

</div>

I have this code to start 4 prog in 4 separate threads. however 2 of  
the ibScans and  
emailProcessing threads are not even starting. dunno why.

ibScans and emailProcessing are not even starting and i dont see the  
puts hitting it at all.  
#require ‘sendmail’  
require ‘twsFunctions’  
require ‘sendGmail’

def startIB  
@ibThread=Thread.new do  
system(“start E:\TradingTools\IBController  
\IBControllerStart\_customised.bat”)

```
       end
       @ibThread.join

       puts "ib started #{ @ibThread.status}"

```

end

def ibScans  
@ibScansThread=Thread.new do  
load ‘twsScans.rb’  
end  
@ibScansThread.join  
puts “ib scans started #{ @ibScansThread.status}”

end  
def abScans  
@abScansThread =Thread.new do  
load “ABScans.rb”  
end  
@abScansThread.join  
puts “ab scans started #{ @abScansThread.status}”  
end  
def emailProcessing  
@emailThread=Thread.new do  
while true

```
        load 'ScansNotifier.rb'
        sleep(30)
    end

end

```

end

startIB  
abScans  
ibScans  
emailProcessing

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 3, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/some-threads-are-not-starting/124933/2 "2008-01-03T22:39:05Z")

</div>

On Jan 3, 2008, at 1:05 PM, Junkone wrote:

> emailProcessing threads are not even starting. dunno why.

unless you have a _very_ good reason not too always put

Thread.current.abort\_on\_exception

at the top of every Thread.new block

if you don’t see an exception getting raise then one of two things is  
happening:

- the threads are blocked somehow
- you have blocked on the threads

i notice you are joining the thread in startIB - do you realize this  
is _exactly_ like not using a thread at all? why are you joining  
that thread?

unless “start E:\TradingTools\IBController  
\IBControllerStart\_customised.bat” exits instantly you are  
instructing your program to wait until it finished before continuing.

regards.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 3, 2008, 11:30pm UTC](https://www.ruby-forum.com/t/some-threads-are-not-starting/124933/3 "2008-01-03T23:30:49Z")

</div>

On Jan 3, 4:37 pm, “ara.t.howard” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if you don’t see an exception getting raise then one of two things is  
> \IBControllerStart\_customised.bat" exits instantly you are  
> instructing your program to wait until it finished before continuing.
> 
> regards.
> 
> ## a @[http://codeforpeople.com/](http://codeforpeople.com/)
> 
> we can deny everything, except that we have the possibility of being  
> better. simply reflect on that.  
> h.h. the 14th dalai lama

you mean like  
@abScansThread =Thread.new do  
Thread.current.abort\_on\_exception

```
load "ABScans.rb"
end

```

or like this

Thread.current.abort\_on\_exception  
@abScansThread =Thread.new do  
load “ABScans.rb”  
end
