Кто подскажет: В чём проблема?
package com.javarush.task.task16.task1623;
/*
Рекурсивное создание нитей
*/
public class Solution {
static int count = 15;
static volatile int createdThreadCount = 1;
public static void main(String[] args) {
new GenerateThread();
}
public static class GenerateThread extends Thread{
public GenerateThread(){
super(String.valueOf(createdThreadCount));
createdThreadCount++;
try{
this.sleep(5);
}
catch(InterruptedException e){}
this.start();
}
public void run(){
//System.out.println(this);
if(createdThreadCount <= count) {
try{
Thread thr = new GenerateThread();
System.out.println(thr);
thr.join();
}
catch(InterruptedException e){}
}
else System.out.println(this);
}
@Override
public String toString(){
return Thread.currentThread().getName() + " created";
}
}
}