Commit 63696f85 authored by julanar.ali's avatar julanar.ali

adding testing

parent 9d46b2d2
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
package ThreadPoolTests;
import ThreadPool.ThreadPool;
import org.junit.Test;
import static org.junit.Assert.fail;
public class testThreadPool {
@Test
public void testThreadPool() {
ThreadPool threadPool = new ThreadPool(3, 10);
for (int i = 0; i < 10; i++) {
int taskNo = i;
try {
threadPool.execute(() -> {
String message = Thread.currentThread().getName() + ": Task " + taskNo;
System.out.println(message);
});
} catch (Exception e) {
fail("Exception should not be thrown");
}
}
threadPool.waitUntilAllTasksFinished(5000);
threadPool.stop();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment