a quick and dirty methodology which might contain syntax errors :P
class JobManager
def initialize
@threads =[]
end
def registered_jobs
@registered_jobs ||= [Job1.new, Job2.new]
end
def start_jobs
registered_jobs.each {|j| @threads << Thread.new { j.run } }
end
def statuses?
registered_jobs.collect {|j| j.status? }
end
end
Usage:
manager = JobManager.new
manager.start_jobs
# elsewhere
manager.statuses? # returns [Job1.status?, Job2.status?]
This is the sort of idiom I'd use in my code. It's important to be aware that the status variables are subject to race conditions if they are not properly guarded against concurrent modification and access.