Added compiler memory barriers.
Implemented thread join.