This is my 1st day at this amazing forum .
Here comes one of my doubt . well NEW key is used to create an Object of non-static members RIGHT . Actually problem is in multi-threading NEW keyword is used under a non-static block of a constructor to create new thread like t1 = new thread(method_name) .
So plz Clarify me what's going on here . Hope everything clarifies my doubt :)
Thanks in advance


VulpesRank #55 · 29.2K reputationPosted Feb 6, 2013, 8:42 AM EST
The output should be:
VulpesRank #55 · 29.2K reputationPosted Feb 5, 2013, 1:04 AM EST
Thread t1 = new Thread(new ThreadStart(method_name));
The Thread class's constructor needs to be passed a ThreadStart delegate which tells it what method to execute when the thread starts.
So when you do this:
Thread t1 = new Thread(method_name);
the C# compiler automatically creates a ThreadStart delegate based on method_name and passes that to Thread's constructor.
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 5, 2013, 8:19 AM EST
Thanks for the quick reply but my doubt here is regarding NEW keyword that used to create a thread under non-static constructor.
PS:In C# rules we cant create a obj or etc using NEW keyword under non-static block of code i.e constructor .
Thank you
VulpesRank #55 · 29.2K reputationPosted Feb 5, 2013, 9:06 AM EST
For example, this compiles and runs fine:
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 5, 2013, 4:30 PM EST
I just want explanation on NEW keyword just NEW keyword used in thread creation under instance constructor like u said .
I am thinking NEW keyword is used only under static block of code for creating objects or threads etc .. can NEW key used under non-static blocks ?? like above you mentioned under instance constructor ?
Ex:public A()
Thank you
VulpesRank #55 · 29.2K reputationPosted Feb 6, 2013, 1:01 AM EST
What led you to think that it couldn't be used in a non-static block?
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 6, 2013, 7:05 AM EST
By default main method is static method right . we always used to create object of members under Main right :) so basic rule in Object creation is Object can only be created under Static block like Main,any static method or etc that is must !
As obj can created only using NEW key . that fallowed my doubt :)
I hope you got it
Thank you
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 6, 2013, 4:39 PM EST
Any ways for further doubts will revert back at you :)