Multithreading engine

Multithreading engine implementation based on entranceprocessor branch's new interface. 
Please review.