Runtime Mechanisms for Efficient Dynamic Multithreading