вроде всё ок
package com.javarush.task.task16.task1623;
/*
Рекурсивное создание нитей
*/
public class Solution {
static int count = 15;
static volatile int createdThreadCount = 0;
public static void main(String[] args) throws InterruptedException {
for (int i = createdThreadCount; i <= count; i++) {
Thread.sleep(1500);
GenerateThread th = new GenerateThread();
// th.join();
}
}
public static class GenerateThread extends Thread{
@Override
public String toString() {
return getName() + " created";
}
public GenerateThread(){
super("" + createdThreadCount++);
start();
}
@Override
public void run() {
if(createdThreadCount<=count){
System.out.println(new GenerateThread().toString());
}
}
}
}