I only get one line of output. I revisited each line a couple of times and can't find what's the problem. It only creates one object WhyTheFace?!
package com.codegym.task.task16.task1623;
/*
Creating threads recursively
*/
public class Solution {
static int count = 15;
static volatile int createdThreadCount;
public static void main(String[] args) {
System.out.println(new GenerateThread());
}
public static class GenerateThread extends Thread {
public GenerateThread() {
super(String.valueOf(++createdThreadCount));
start();
}
public void run() {
if (createdThreadCount < count) {
new GenerateThread();
}
}
@Override
public String toString() {
return String.format("%s created", getName());
}
}
}