I have a case-study for an Android interview. I just wanted to get your opinion before I share the code with the company.There are two fragments: one of them uses a thread-callback structure and the other uses a thread-handler-message structure.Which of them are more robust, well structured, and understandable for a mobile app?(I intentionally haven't made any comments to see code readability)Grab content from web:get 10th characterget every 10th charactercount word by splitting white space and use a proper data structure because the UI can ask for a specific word count.Thread - Callbackpublic class PlaceholderFragmentThreadCallback extends Fragment implements View.OnClickListener {        private final static String TAG = PlaceholderFragment;        private final String REQUEST_URL = http://www.lipsum.com/;        private static final String searchKeyword = Lorem;        private Button btnGo;        private TextView txtContent, txtTitle;        private ProgressBar freezeTestProgress;        interface OnWorkOneDone {            void OnWorkOneDone(String character);        }        interface OnWorkTwoDone {            void OnWorkOneDone(String character);        }        interface OnWorkThreeDone {            void OnWorkOneDone(HashMap<String, Integer> map);        }        public static PlaceholderFragmentThreadCallback getInstance() {           return new PlaceholderFragmentThreadCallback();        }        @Override        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {            View rootView = inflater.inflate(R.layout.fragment_main, container, false);            btnGo = (Button) rootView.findViewById(R.id.btn_Go);            txtContent = (TextView) rootView.findViewById(R.id.content);            txtTitle = (TextView) rootView.findViewById(R.id.title);            txtTitle.setText(Thread - Callback);            freezeTestProgress = (ProgressBar) rootView.findViewById(R.id.progressBar1);            txtContent.setVisibility(View.GONE);            btnGo.setOnClickListener(this);            return rootView;        }        private void WebContentRequest() {            StringRequest request = new StringRequest(Request.Method.GET, REQUEST_URL, new Response.Listener<String>() {                @Override                public void onResponse(String response) {                    Log.v(TAG, response);                    Thread thread1 = new Thread(new WorkerThread1(new OnWorkOneDone() {                        @Override                        public void OnWorkOneDone(String character) {                            updateTextView(Character 10 th is + character);                        }                    }, response));                    Thread thread2 = new Thread(new WorkerThread2(new OnWorkTwoDone() {                        @Override                        public void OnWorkOneDone(String character) {                            updateTextView(character);                        }                    }, response));                    Thread thread3 = new Thread(new WorkerThread3(new OnWorkThreeDone() {                        @Override                        public void OnWorkOneDone(HashMap<String, Integer> map) {                            updateTextView(findWordCountIn(map));                        }                    }, response));                    thread1.start();                    thread2.start();                    thread3.start();                }            }, new Response.ErrorListener() {                @Override                public void onErrorResponse(VolleyError error) {                    Log.v(TAG, error.getMessage());                }            });            MyVolley.getInstance(getActivity().getApplicationContext()).addToRequestQueue(request);        }        private synchronized void updateTextView(final String value) {            getActivity().runOnUiThread(new Runnable() {                @Override                public void run() {                    txtContent.setText(txtContent.getText().toString() + value + System.getProperty(line.separator));                    if (freezeTestProgress.getVisibility() == View.VISIBLE) {                        freezeTestProgress.setVisibility(View.GONE);                        txtContent.setVisibility(View.VISIBLE);                    }                }            });        }        private String findWordCountIn(HashMap<String, Integer> map) {            if (map.get(searchKeyword) != null)                return searchKeyword +  count is  + map.get(searchKeyword).toString();            else                return searchKeyword +  not found.;        }        @Override        public void onClick(View v) {            switch (v.getId()) {                case R.id.btn_Go:                    freezeTestProgress.setVisibility(View.VISIBLE);                    WebContentRequest();                    break;            }        }        private static class WorkerThread1 implements Runnable {            OnWorkOneDone onWorkOneDone;            String webContent;            private WorkerThread1(OnWorkOneDone onWorkOneDone, String webContent) {                this.onWorkOneDone = onWorkOneDone;                this.webContent = webContent;            }            @Override            public void run() {                if (webContent.length() < 10)                    return;                Log.e(TAG, webContent.substring(9, 10));                String value = webContent.substring(9, 10);                if (value.equalsIgnoreCase( ))                    value = { };                Log.e(TAG, handleMessage   + value);                onWorkOneDone.OnWorkOneDone(value);            }        }        private static class WorkerThread2 implements Runnable {            OnWorkTwoDone onWorkTwoDone;            String webContent;            private WorkerThread2(OnWorkTwoDone onWorkTwoDone, String webContent) {                this.onWorkTwoDone = onWorkTwoDone;                this.webContent = webContent;            }            @Override            public void run() {                if (webContent.length() < 10)                    return;                onWorkTwoDone.OnWorkOneDone(findEvery10thCharacterIn(webContent));            }            private String findEvery10thCharacterIn(String webContent) {                StringBuilder sb = new StringBuilder();                sb.append(System.getProperty(line.separator));                int modIndex = 1;                for (int i = 0; i < webContent.length(); i++) {                    if (i % 10 == 0 && (10 * modIndex) + 1 < webContent.length()) {                        sb.append(webContent.substring(10 * modIndex, (10 * modIndex) + 1));                        modIndex++;                    }                }                sb.append(System.getProperty(line.separator));                return sb.toString();            }        }        private static class WorkerThread3 implements Runnable {            OnWorkThreeDone onWorkThreeDone;            String webContent;            private WorkerThread3(OnWorkThreeDone onWorkThreeDone, String webContent) {                this.onWorkThreeDone = onWorkThreeDone;                this.webContent = webContent;            }            @Override            public void run() {                if (webContent.length() < 0)                    return;                HashMap<String, Integer> wordMap = calculateWordCountsIn(webContent);                onWorkThreeDone.OnWorkOneDone(wordMap);            }            private HashMap calculateWordCountsIn(String webContent) {                HashMap<String, Integer> wordMap = new HashMap<>();                String[] s = webContent.split( );                for (int i = 0; i < s.length; i++) {                    Log.v(map_count, s[i]);                    if (wordMap.containsKey(s[i])) {                        wordMap.put(s[i], Integer.valueOf(wordMap.get(s[i])) + 1);                    } else                        wordMap.put(s[i], 1);                }                return wordMap;            }        }    }Thread - Handler - Messagepublic class PlaceholderFragmentThreadHandlerMessage extends Fragment implements View.OnClickListener {    private final String TAG = PlaceholderFragment;    private final String REQUEST_URL = http://www.lipsum.com/;    private final int MSG_SUCCESS = 100;    private final int MSG_ERROR = 200;    private final int MSG_10TH = 300;    private final int MSG_EVERY10TH = 301;    private final int MSG_COUNT_WORD = 302;    private Button btnGo;    private TextView txtContent, txtTitle;    private ProgressBar freezeTestProgress;    private Handler workerThreadOneHandler;    private Handler workerThreadTwoHandler;    private Handler workerThreadThreeHandler;    private final String searchKeyword = Lorem;    public static PlaceholderFragmentThreadHandlerMessage getInstance() {        return new PlaceholderFragmentThreadHandlerMessage();    }    private void touchUI(int what, String text) {        switch (what) {            case MSG_10TH:                updateTextView(Character 10 th is + text);                break;            case MSG_EVERY10TH:                updateTextView(text);                break;            case MSG_COUNT_WORD:                updateTextView(text);                break;        }    }    @Override    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {        View rootView = inflater.inflate(R.layout.fragment_main, container, false);        btnGo = (Button) rootView.findViewById(R.id.btn_Go);        txtContent = (TextView) rootView.findViewById(R.id.content);        freezeTestProgress = (ProgressBar) rootView.findViewById(R.id.progressBar1);        txtTitle = (TextView) rootView.findViewById(R.id.title);        txtContent.setVisibility(View.GONE);        btnGo.setOnClickListener(this);        txtTitle.setText(Thread - Handler - Message);        Thread workerThreadOne = new Thread() {            @Override            public void run() {                Looper.prepare();                workerThreadOneHandler = new Handler() {                    @Override                    public void handleMessage(Message msg) {                        if (msg.obj == null)                            return;                        if (msg.obj.toString().length() < 10)                            return;                        switch (msg.what) {                            case MSG_SUCCESS:                                Log.e(TAG, msg.obj.toString().substring(9, 10));                                String value = msg.obj.toString().substring(9, 10);                                if (value.equalsIgnoreCase( ))                                    value = { };                                Log.e(TAG, handleMessage   + value);                                touchUI(MSG_10TH, value);                                break;                            case MSG_ERROR:                                break;                        }                    }                };                Looper.loop();            }        };        workerThreadOne.start();        Thread workerThreadTwo = new Thread() {            @Override            public void run() {                Looper.prepare();                workerThreadTwoHandler = new Handler() {                    @Override                    public void handleMessage(Message msg) {                        if (msg.obj == null)                            return;                        if (msg.obj.toString().length() < 0)                            return;                        touchUI(MSG_10TH, findEvery10thCharacterIn(msg.obj.toString()));                    }                    private String findEvery10thCharacterIn(String webContent) {                        StringBuilder sb = new StringBuilder();                        sb.append(System.getProperty(line.separator));                        int modIndex = 1;                        for (int i = 0; i < webContent.length(); i++) {                            if (i % 10 == 0 && (10 * modIndex) + 1 < webContent.length()) {                                sb.append(webContent.substring(10 * modIndex, (10 * modIndex) + 1));                                modIndex++;                            }                        }                        sb.append(System.getProperty(line.separator));                        return sb.toString();                    }                };                Looper.loop();            }        };        workerThreadTwo.start();        Thread workerThreadThree = new Thread() {            @Override            public void run() {                Looper.prepare();                workerThreadThreeHandler = new Handler() {                    @Override                    public void handleMessage(Message msg) {                        if (msg.obj == null)                            return;                        if (msg.obj.toString().length() < 0)                            return;                        HashMap<String, Integer> wordMap = calculateWordCountsIn(msg.obj.toString());                        touchUI(MSG_10TH, findWordCountIn(wordMap));                    }                    private HashMap calculateWordCountsIn(String webContent) {                        HashMap<String, Integer> wordMap = new HashMap<>();                        String[] s = webContent.split( );                        for (int i = 0; i < s.length; i++) {                            Log.v(map_count, s[i]);                            if (wordMap.containsKey(s[i])) {                                wordMap.put(s[i], Integer.valueOf(wordMap.get(s[i])) + 1);                            } else                                wordMap.put(s[i], 1);                        }                        return wordMap;                    }                    private String findWordCountIn(HashMap<String, Integer> map) {                        if (map.get(searchKeyword) != null)                            return searchKeyword +  count is  + map.get(searchKeyword).toString();                        else                            return searchKeyword +  not found.;                    }                };                Looper.loop();            }        };        workerThreadThree.start();        return rootView;    }    private void WebContentRequest() {        StringRequest request = new StringRequest(Request.Method.GET, REQUEST_URL, new Response.Listener<String>() {            @Override            public void onResponse(String response) {                Log.v(TAG, response);                workerThreadOneHandler.obtainMessage(MSG_SUCCESS, response).sendToTarget();                workerThreadTwoHandler.obtainMessage(MSG_SUCCESS, response).sendToTarget();                workerThreadThreeHandler.obtainMessage(MSG_SUCCESS, response).sendToTarget();            }        }, new Response.ErrorListener() {            @Override            public void onErrorResponse(VolleyError error) {                Log.v(TAG, error.getMessage());            }        });        MyVolley.getInstance(getActivity().getApplicationContext()).addToRequestQueue(request);    }    private synchronized void updateTextView(final String value) {        getActivity().runOnUiThread(new Runnable() {            @Override            public void run() {                txtContent.setText(txtContent.getText().toString() + value + System.getProperty(line.separator));                if (freezeTestProgress.getVisibility() == View.VISIBLE) {                    freezeTestProgress.setVisibility(View.GONE);                    txtContent.setVisibility(View.VISIBLE);                }            }        });    }    @Override    public void onClick(View v) {        switch (v.getId()) {            case R.id.btn_Go:                freezeTestProgress.setVisibility(View.VISIBLE);                WebContentRequest();                break;        }    }}
Simultaneous works with multithreading
java;multithreading;android