multithreading - Will Keyword NEW reinitialize all others running function value in c#? -
i have class file perform function , example
public class clsfunction { public datatable functionone() { //some code } public void functiontwo() { //some code } }
secondclass use call function clsfunction , , main class in running on console program multiple thread.
public class secondclass { public void threadone() { while(true){datatable dt = new clsfunction().functionone;} } public void threadtwo() { while(true){new clsfunction().functiontwo();} } } class main { static void main (string[] args) { //thread start secondclass.threadone //thread start secondclass.threadtwo } }
my concern class value reinitialize default value when call new clsfunction()
each time. example , thread 2 may running own value , when thread 1 call , thread 2 value change default value ?
maybe don't understand new does. creates object. it's purpose not initialize exists. objects independent.
creating object has no influence on other object, except of course if constructor influence other objects.
Comments
Post a Comment