“To hang on by a thread” is an idiom that means to be in a very uncertain, unstable state. Going one step further, it can mean “unlikely to succeed.”*
After a number of people filed complaints with Human Resources against Luke, his employment with ABC Insurance was hanging on by a thread.
This idiom is derived from the ancient legend of Damocles. Alluding to a sword suspended above the head of Damocles by a single hair, this idiom become most popular in the 16th century, referring to anything that was in a precarious or perilous state.**
** Dictionary of Idioms and Their Origins, Linda and Roger Flavell, page 291