Merge -c 1227426 from trunk to branch-0.23 to fix MAPREDUCE-3572. Moved AM event dispatcher to a separate thread for performance reasons.