Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new Thread(method) vs new Thread(new ThreadStart(method))? [duplicate]

What is the difference between...

Thread MyThread = new Thread(ChangeColor);

vs.

Thread MyThread = new Thread(new ThreadStart(ChangeColor));

Both are starting a new thread but is there a difference between doing it one way vs. the other?

like image 525
psj01 Avatar asked Mar 11 '26 21:03

psj01


1 Answers

Nothing. You're effectively asking the difference between:

ThreadStart threadStart = ChangeColor;

and

ThreadStart threadStart = new ThreadStart(ChangeColor);

The first is an implicit method group conversion. Both result in the same compiled code.

like image 74
Charles Mager Avatar answered Mar 14 '26 10:03

Charles Mager



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!