@Override
    public void run() {
        //System.out.println("Log thread started");
        while (!terminated || (strings.size() != 0)) {
            if (strings.size() != 0) {
                try {
                    out.write(strings.get(0));
                    out.newLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                strings.remove(0);
            }
        }

        try {
            String hours = new SimpleDateFormat("HH").format(Calendar.getInstance().getTime());
            String minutes = new SimpleDateFormat("mm").format(Calendar.getInstance().getTime());
            String seconds = new SimpleDateFormat("ss").format(Calendar.getInstance().getTime());
            String millis = new SimpleDateFormat("SSS").format(Calendar.getInstance().getTime());
            String startTimeLog = hours + ":" + minutes + ":" + seconds + ":" + millis;

            out.write("[Log ended at " + startTimeLog + "]");

            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //System.out.println("Log thread terminated");
    }