title: How to implement a thread safe timer on linux?
body: <p>As we know, doing things in signal handlers is really bad, because they run in an interrupt-like context. It's quite possible that various locks (including the malloc() heap lock!) are held when the signal handler is called.</p>
  
  <p>So I want to implement a thread safe timer without using signal mechanism.</p>
  
  <p>How can I do?</p>
  
  <p>Sorry, actually, I'm not expecting answers about thread-safe, but answers about implementing a timer on Unix or Linux which is thread-safe.</p>