private static String removeThisThread(String threadDumpOutput) {
    Thread thisThread = Thread.currentThread();
    String threadName = thisThread.getName();
    long threadId = thisThread.getId();

    List<String> lines = Arrays.asList(threadDumpOutput.split("\n"));
    Pair<Integer, Integer> thisThreadSection = findThreadSection(lines, threadName, threadId);
    if (thisThreadSection == null) {
      return threadDumpOutput;
    }

    String start = TextUtil.join("\n", lines.subList(0, thisThreadSection.first()));
    int thisThreadSectionStop = thisThreadSection.second();
    if (thisThreadSectionStop == lines.size()) {
      return start;
    } else {
      return start + TextUtil.join("\n", lines.subList(thisThreadSectionStop + 1, lines.size() - 1));
    }
  }
Times out a method invocation if it takes too long. The method invocation
will occur on the regular test framework thread. This can be important
for integration tests with thread-local state.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/TimeoutInterceptor.java