package ru.apetrov;

/**
 * Created by Andrey on 16.06.2017.
 */
public class MyThread {

    private SpaceThreads spaceThreads;
    private WordThreads wordThreads;
    private String text;

    public MyThread(String text) {
        this.text = text;
        this.spaceThreads = new SpaceThreads(text);
        this.wordThreads = new WordThreads(text);
    }

    private void startThreads() {
        System.out.printf("%s\n%s%s\n", "Start the program:", "Text to check: - ", this.text);
        Thread thread1 = new Thread(this.spaceThreads);
        Thread thread2 = new Thread(this.wordThreads);
        thread1.start();
        thread2.start();
        try {
            thread1.join();
            thread2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Finish of the program!");
    }

    public static void main(String[] args) {
        new MyThread("String for checking the execution of the program").startThreads();
    }
}

@@ -14,16 +14,43 @@
 etrov;%0A%0A
+import java.util.Scanner;%0A%0A
 /**%0A * C
@@ -898,134 +898,457 @@
    p
-ublic static void main(String%5B%5D args) %7B%0A        new MyThread(%22String for checking the execution of the program%22).startThreads(
+rivate static String inputText() %7B%0A        Scanner scanner = new Scanner(System.in);%0A        System.out.println(%22Input text:%22);%0A        return scanner.nextLine();%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        String text = MyThread.inputText();%0A        long start = System.currentTimeMillis();%0A        new MyThread(text).startThreads();%0A        long finish = System.currentTimeMillis() - start;%0A        System.out.println(finish + %22ms%22
 );%0A 

add lesson 6.1.2 (Threads)