We propose an experimentally feasible scheme for preparing a four-atom cluster state in a thermal cavity. In the scheme, the cavity field is only virtually excited and the photon-number-dependent part in the effective Hamiltonian is cancelled so that the system is insensitive to the cavity decay and the thermal field. At the same time, the scheme can be generalized to prepare n-atom cluster states with the success probability 100%. In addition, using the four-atom cluster state, we also propose a simpler scheme for implementing a remote-controlled not gate (CNOT) without the Bell states measurement.