Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.function.Supplier; public class Main { public static Collection<Thread> getThreads(int count, Supplier<Thread> threadSupplier) { Collection<Thread> threads = new ArrayList<>(count); for (int i = 0; i < count; i++) { threads.add(threadSupplier.get()); } return threads; } }