Starting a Thread when Nginx starts

Hi,
I am new to Nginx. Have gone through evanmiller blog and nginxguts to
write my own module. Wrote a hello module which is working fine.
I extended the hello module and in the http handler, it could start the
thread. I have used pthread library for this. Now I want to start a
thread of my own along with nginx and not with a http handler.

  1. What modification is required to make it?
  2. How to stop the thread when nginx is exiting?
  3. Is there a different way of doing it other than pthread for a
    background activity.

Posted at Nginx Forum: