[runtime] Move more thread attach code to mono-threads from io-layer.