Quote Originally Posted by Slobodan46 View Post
I've checked your code again and the problem with it is that I want to choose the number of threads by myself by entering it in the console. ... Do you understand my problem?
We understand, but understand that we aren't going to do your homework for you.

What you need to do is to break the problem down and determine what is missing from your program.

Consider the following code snippet:
Code:
 
static void Main(string[] args)
{
  RunThreads(10);
}
Since your requirement is to specify the number of threads in the command line, you need to figure out how to change the hardcoded 10 value in the RunThreads(10); statement into some value that gets passed in:
Code:
 
static void Main(string[] args)
{
  RunThreads( threadCount );  // TODO: threadCount needs to be passed in
}
If the RunThreads method has been coded properly so that it creates a number of threads based on the value passed into the method, your work is done.

The secret to solving this is that string[] args contains an array of command line arguments.

Given that, take a look at this article and see if you can figure out what you need to do (hint: without error checking, it's one line of code).

http://www.c-sharpcorner.com/UploadF...dLineArgs.aspx