Created
May 8, 2013 03:12
-
-
Save konard/5537930 to your computer and use it in GitHub Desktop.
ThreadHelpers is a static class (module) containing utility methods to deal with System.Threading.Thread class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Threading; | |
| namespace Helpers | |
| { | |
| public static class ThreadHelpers | |
| { | |
| public static Thread[] CreateThreads(ThreadStart action, int amount, int maxStackSize) | |
| { | |
| Thread[] threads = new Thread[amount]; | |
| for (int i = 0; i < threads.Length; i++) | |
| threads[i] = new Thread(action, maxStackSize); | |
| return threads; | |
| } | |
| public static Thread[] CreateThreads(ThreadStart action, int amount) | |
| { | |
| Thread[] threads = new Thread[amount]; | |
| for (int i = 0; i < threads.Length; i++) | |
| threads[i] = new Thread(action); | |
| return threads; | |
| } | |
| public static Thread[] CreateThreads(ParameterizedThreadStart function, int amount, int maxStackSize) | |
| { | |
| Thread[] threads = new Thread[amount]; | |
| for (int i = 0; i < threads.Length; i++) | |
| threads[i] = new Thread(function, maxStackSize); | |
| return threads; | |
| } | |
| public static Thread[] CreateThreads(ParameterizedThreadStart function, int amount) | |
| { | |
| Thread[] threads = new Thread[amount]; | |
| for (int i = 0; i < threads.Length; i++) | |
| threads[i] = new Thread(function); | |
| return threads; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment