1. Why does all result_view get rendered the same time irrespective of
the requests? How can i resolve this?
2. Will migrating code from the controller to the view do any help?
3. How can i reduce the response time (Either by using threads or any
I think the reason why your threads don't behave like threads is that
you have overwritten the run() method.
You shouldn't subclass Thread. Instead, use blocks like this:
t = Thread.new( some_variable ) do |some_variable|
# do stuff with the variable here
Thread.current["result"] = some_result_calculated
Once the thread finished running, you can use t["result"] to get the
If you need to do any more complex calculations in the thread,
refactor those into a separate class and do something like
t = Thread.new( query ) do |query |
Thread.current["result"] = QueryProcessor.new.query_parse(query )