Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task16.task1623;
- /*
- Рекурсивное создание нитей
- */
- public class Solution {
- static int count = 15;
- static volatile int countCreatedThreads;
- public static void main(String[] args) {
- System.out.println(new GenerateThread());
- }
- public static class GenerateThread extends Thread {
- @Override
- public String toString() {
- return (getName() + " created");
- }
- public GenerateThread () {
- super(String.valueOf(++countCreatedThreads));
- start();
- }
- public void run() {
- if (countCreatedThreads < (Solution.count)) {
- new GenerateThread();
- System.out.println(this);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement