Saturday, 28 May 2011

sMash: Merge results from multiple queries in parallel

def th1Results, th2Results

def th1 = Thread.start {
// do query here
th1Results = blah()
}
def th2 = Thread.start {
// do query here
th2Results = blah()
}
//-- Join all results when all threads complete.
th1.join();
th2.join();
logger.INFO{'threads complete'}
def allResults = [
"foo" : th1results,
"bar" : th2Results]

The join() calls basically wait to complete.

No comments:

Post a Comment