Witam , a o to i podpowiedz ,
- Jeżeli liczba utworzonych wątków jest mniejsza niż Solution.count, metoda run musi wyświetlać utworzony wątek.
Według mnie już program powinien ten warunek przejść ale własnie nie chce wiec może dacie mi jakieś wskazówki.
/*
Rekurencyjne tworzenie wątków
*/
public class Solution {
static int count = 15;
static volatile int createdThreadCount;
public static void main(String[] args) {
System.out.println(new GenerateThread());
//new GenerateThread();
}
public static class GenerateThread extends Thread {
public GenerateThread() {
super(String.valueOf(++createdThreadCount));
start();
}
@Override
public String toString() {
return getName() + " utworzony";
}
@Override
public void run() {
if(createdThreadCount < Solution.count){
System.out.println(new GenerateThread());
}
if(createdThreadCount <= Solution.count){
System.out.println(this.toString());
}
}
}
}