@@ -0,0 +1,1587 @@
+package ru.job4j.threads;%0A%0Apublic class NumberWordsAndSpaces %7B%0A%0A    public String str;%0A    private int countSpaces = 0;%0A    private int countWords = 0;%0A%0A    public NumberWordsAndSpaces(String str) %7B%0A        this.str = str;%0A    %7D%0A%0A    public void counting() %7B%0A        String word = %22%22;%0A        int innerCount = 0;%0A        for (int i = 0; i %3C str.length(); i++) %7B%0A            if (innerCount == str.length() - 1 && str.charAt(i)!=' ') %7B%0A                countWords++;%0A            %7D%0A            if ( str.charAt(i) != ' ') %7B%0A                word = word + Character.toString( str.charAt(i) );%0A            %7D else %7B%0A                if (!word.equals(%22%22)) %7B%0A                    word = %22%22;%0A                    countWords++;%0A                %7D%0A                countSpaces++;%0A            %7D%0A            innerCount++;%0A        %7D%0A    %7D%0A%0A    public int countWords() %7B%0A        return countWords;%0A    %7D%0A%0A    public int countSpaces() %7B%0A        return countSpaces;%0A    %7D%0A%0A    public static final class CalculateWords implements  Runnable %7B%0A        @Override%0A        public void run() %7B%0A            NumberWordsAndSpaces nws = new NumberWordsAndSpaces(%22word1 word2 word3   word4    word5 word6%22);%0A            nws.counting();%0A            System.out.println(nws.countWords());%0A        %7D%0A    %7D%0A%0A    public static final class CalculateSpaces implements Runnable %7B%0A        @Override%0A        public void run() %7B%0A            NumberWordsAndSpaces nws = new NumberWordsAndSpaces(%22word1 word2 word3   word4    word5 word6%22);%0A            nws.counting();%0A            System.out.println(nws.countSpaces());%0A        %7D%0A    %7D%0A%0A%7D%0A

task #1016