Перед валидацией проверил работу программы - адекватно считает и кладет в resultMap... В чем проблема?
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 static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String ex = null;
while (true){
ex = reader.readLine();
if (ex.equals("exit")) break;
else new ReadThread(ex).start();
}
reader.close();
}
public static class ReadThread extends Thread {
private volatile FileInputStream f;
private volatile String fileName;
private static HashMap<String, Integer> resultMap = new HashMap();
public ReadThread(String fileName) throws IOException {
f = new FileInputStream(fileName);
this.fileName = fileName;
}
@Override
public void run() {
HashMap<Integer, Integer> bufMap = new HashMap();
Integer buf = 0;
try {
while (f.available() != 0) {
buf = f.read();
if (!bufMap.keySet().contains(buf)) bufMap.put(buf, 1);
else bufMap.replace(buf, bufMap.get(buf) + 1);
}
} catch (IOException e){}
Integer max = 0;
Integer maxkey = 0;
for (Integer x: bufMap.keySet()) {
if (bufMap.get(x) >= max) {
max = bufMap.get(x);
maxkey = x;
}
}
synchronized (resultMap) {
resultMap.put(fileName, maxkey);
}
try {
f.close();
} catch (IOException e){}
}
}
}