
Other actions such as withLinksDo and forkLinkIO' insert stuff into threadMap. It can be non-mepty.
Thanks (again), Albert. Later, I found this comment above the 'withLinksDo' function: "It is an error to call this function outside the main thread, or to call any other functions in this module outside this function." Here's the simplest example that doesn't return the exception: instance Show ThreadId where show (Tid u) = show . hashUnique $ u main = do tid <- C.myThreadId tid' <- fmap Tid newUnique modifyMVar_ threadMap $ \tm -> return $ tm { state = M.singleton tid $ ThreadState { ident = tid' , signal = defaultSignal tid , links = S.empty , monitors = M.empty , ownedMons = S.empty } } myThreadId