Why does an IllegalThreadStateException occur when Thread.start is called again

后端 未结 7 1572
攒了一身酷
攒了一身酷 2020-12-01 16:15
public class SieveGenerator{

static int N = 50;
public static void main(String args[]){

    int cores = Runtime.getRuntime().availableProcessors();

    int f[] =          


        
相关标签:
7条回答
  • 2020-12-01 16:55

    The Thread.isAlive() method can tell you if the Thread has already been started. Simply do this where you want to start your thread:

       if(!t[p%cores].isAlive()){
           t[p%cores].start();
       }
    
    0 讨论(0)
提交回复
热议问题