Fixed bug , decrementing thread->timer inside the if (thread->timer>0)