An M/M/1 queueing system with an unreliable device is considered in the study. The device fails in an exponentially distributed time during which it is in the working condition and serves a demand. The device recovers during an exponentially distributed time according to the threshold policy specified by threshold level q ≥ 1. After a successive failure, the device does not recover until the number of demands exceeds level q. In the study, the system operating in the stationary regime is analyzed and the problem of optimal recovery control aimed at the minimization of the mean cost for a given penalty structure is solved.