So I'm trying to familiarise myself with concurrent programing in java so I wrote the following code
public class Test{
public static void main(String[] args){
ForkJoinPool pool = new ForkJoinPool();
pool.invoke(new Agent());
}
}
class thread extends RecursiveTask<Integer>{
thread(){
System.out.println("Thread");
}
public Integer compute(){
thread x = new thread();
x.fork();
return 0;
}
}
which as far as I understand should print 'Thread' infinitely but when I run it only print 'Thread' about 20 times.
Does anybody know why?
tthreadis a terrible pattern btw.MyRecursiveTaskwould be a better name.