class WorkerThread extends Thread {
    @Override
    public void run() {<FILL_FUNCTION_BODY>}
  }

      try (SqlSession session = sessionFactory.openSession(ExecutorType.BATCH, false)) {
        while (!Thread.currentThread().isInterrupted()) {
          int batchSize = 0;
          long batchTime = System.currentTimeMillis();
          // commit when batch size is reached or after waiting period elapsed
          while(!Thread.currentThread().isInterrupted()
            && batchSize < SQL_BATCH_SIZE
            && System.currentTimeMillis() - batchTime < SQL_BATCH_WAITING_TIME)  {
            if (messages.size() > SQL_BATCH_SIZE) {
              ServerTools.print(String.format("Logging queue filling up: %d entries", messages.size()));
            }
            // polling to be able to react when waiting time has elapsed
            DatabaseLogEntry entry = messages.poll(POLLING_TIME, TimeUnit.MILLISECONDS);
            if (entry == null) {
              continue;
            }
            batchSize++;
            session.insert(entry.getMappingIdentifier(), entry.getMapping());
            DatabaseLogEntry followup = entry.followup();
            if (followup != null) { // followup statements need to be inserted directly afterwards, dependent on e.g. generated primary keys
              session.insert(followup.getMappingIdentifier(), followup.getMapping());
              batchSize++;
            }
          }
          session.commit();
        }
      } catch (Exception e) {
        e.printStackTrace();
        if (!Thread.currentThread().isInterrupted()) {
          new WorkerThread().start();
        }
      }
    
<no_super_class>