Валидатор не принимает!!
package com.javarush.task.task16.task1623;
/*
Рекурсивное создание нитей
*/
public class Solution {
static int count = 15;
static volatile int createdThreadCount = 1;
public static void main(String[] args) {
createdThreadCount = 1;
GenerateThread thread = new GenerateThread();
try {
thread.join();
} catch (Exception e) {
}
System.out.println(thread);
}
public static class GenerateThread extends Thread {
public static String n = "" + createdThreadCount;
public GenerateThread() {
super(GenerateThread.n);
// System.out.println(createdThreadCount);
start();
createdThreadCount++;
n = "" + createdThreadCount;
}
public void run() {
while (createdThreadCount-1 < Solution.count) {
GenerateThread thread = new GenerateThread();
try {
thread.join();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(thread);
}
}
@Override
public String toString() {
return getName() + " created";
}
}
}