my program doesn't work correctly because this exception

while(count<sharedBetweenThreads.size()){
                for (int i = 0; (i < ourThreads.length)
                        && count < sharedBetweenThreads.size(); i++) {
                    if (ourThreads[i].isAlive() == false) {
                       
                        ourThreads[i].start();

                    }
                }

if the length of an array of threads(ourthreads) equal 2.
the two threads start and then the program check the while condition and if it's true
he check if ourThreads.isAlive() == false and then the thread must start
but unfouretantly ,it's throw this exception

please how can I solve this problem

Because the thread was probably already started and is simply finished now. Once that happens you cannot restart it, you must create a new one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.