Merge pull request #164 from tdas/kafka-fix

Made block generator thread safe to fix Kafka bug.

This is a very important bug fix. Data can and was being lost in the kafka due to this.

(cherry picked from commit dfd1ebc2d1e5c34a5979648e571302ae81a178f5)
Signed-off-by: Reynold Xin <rxin@apache.org>