Не понимаю, что не нравится валидатору.
package com.javarush.task.task18.task1823;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public volatile static boolean isStop = false;
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String fileName = reader.readLine();
if (fileName.equals("exit")) {
isStop = true;
break;
} else {
ReadThread readThread = new ReadThread(fileName);
readThread.start();
}
}
reader.close();
}
public static class ReadThread extends Thread {
private volatile String filename;
private int[] chars = new int[256];
public ReadThread(String fileName) {
//implement constructor body
this.filename = fileName;
}
@Override
public void run() {
try {
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(filename));
while (stream.available() > 0 && !isStop) {
chars[stream.read()]++;
}
stream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
int maxCouns = 0;
for (int i = 0; i < chars.length; i++) {
maxCouns = chars[i] > maxCouns ? chars[i] : maxCouns;
}
for (int i = 0; i < chars.length; i++) {
if (chars[i] == maxCouns) {
synchronized (resultMap) {
resultMap.put(filename, i);
}
}
}
}
}
}