A scheme is proposed for generating a three-atom maximal entanglement W state. It is based on the simultaneous nonresonant interaction of atoms with a single-mode cavity field. Our scheme is insensitive to the cavity field, so the cavity field in our scheme can be initially in thermal states.