some threads are not starting

J

Junkone

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
 
A

ara.t.howard

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/
 
J

Junkone

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/

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top