It is a bit optimistic to think that all timeout threads have been deleted directly after 10ms (at least on Windows where I experimented to figure out if the < 5 was necessary). A safer construct is something like:
```
        long finishNumberOfThreads = Thread.getAllStackTraces().size();
		for (int i = 0; i < 100; i++) {
			if (finishNumberOfThreads == startNumberOfThreads) {
				break;
			}
			Thread.sleep(5);
		    finishNumberOfThreads = Thread.getAllStackTraces().size();
		}
```
It allows for up to 500ms before the number of threads are back to the starting level, but does not sleep longer then on average 2,5ms longer than necessary. So far I have never seen more than a couple of loops actually been needed in practice.