If you use the Sun routines ALARM or SETITIMER on Solaris 2.8, review the bug that is documented in each routine’s man page.
To work around the bug, use alarm and link in pthread ahead of thread, as shown.
-lpthread -lthread