Use task joining mechanism explained by jsuereth.