We consider the threshold optimization problem of cooperative spectrum sensing for cognitive radio (CR) and investigate the threshold optimization algorithm for both single-channel and multichannel cooperative spectrum sensing. In order to obtain the optimal threshold for single-channel cooperative spectrum sensing, we deploy the fusion rules AND Logic, OR Logic, and K-OUT-N Logic. Moreover, an iterative optimization algorithm is proposed to obtain optimal CRs in cooperative spectrum sensing and their optimal thresholds. In multichannel cooperative spectrum sensing, two threshold optimization methods—namely nonrestrained multichannel threshold optimization (NRMTO) and restrained multichannel threshold optimization (RMTO)—have been proposed in order to decrease the total error detection probability of all the subchannels. The simulation results show that in single-channel cooperative spectrum sensing the proposed algorithm outperforms traditional cooperative spectrum sensing with the uniform threshold if the SNR is different, while decreasing the detection performance slightly if the SNR is identical. The results also indicate that the NRMTO can achieve the minimal total error detection probability of multichannel cooperative spectrum sensing, while the RMTO can guarantee the detection performance of each subchannel but with a higher total error detection probability.