package com.javarush.task.task18.task1823;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/*
Нити и байты
*/

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 s;
        while (!(s= reader.readLine()).equals("exit")){
            new ReadThread(s).start();}
        reader.close();

    }

    public static class ReadThread extends Thread {
        private File file;
        private TreeMap<Integer,Integer> allBytes;

        public ReadThread(String fileName){
            this.file = new File(fileName);
            allBytes = new TreeMap<>();

            //implement constructor body
        }

        @Override
        public void run() {

            try(FileInputStream fileInputStream = new FileInputStream(file)) {
                while (fileInputStream.available()>0){
                    int tmp = 0;
                    tmp = fileInputStream.read();
                    if(allBytes.containsKey(tmp)) allBytes.put(tmp, 1+ allBytes.get(tmp));
                    else allBytes.put(tmp,1);
                    int lastItem = allBytes.lastEntry().getKey();
                    resultMap.put(file.getName(), lastItem);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
я хочу понять почему это вариант не работает, скопипастить чужое решение не вариант