Use of Parameterizedthreadstart,threadstart, threads thread Pass parameters

Source: Internet
Author: User

Thread

Threadwithparam =New Thread(New Parameterizedthreadstart(New ThreadTest(). showmsg));//threadwithparam.start ("This is a param.");

Threadwithparam.start (

Thread. Start ();

"44444");Threadthread=New Thread(New ThreadStart(New CLASS11(). showmsg));

Delegate method that represents the method executed on Thread, ThreadStart cannot take parameters, Parameterizedthreadstart is new in 2.0, can take parameters (type of object)

Using System.Threading;

public void ShowMsg ()
{
MessageBox.Show ("Message Info.");
}

Thread thread = new Thread (new ThreadStart (showmsg));
Thread. Start ();

With parameters

public void ShowMsg (Object msg)
{
MessageBox.Show (Msg. ToString ());
}

Thread Threadwithparam = new Thread (new Parameterizedthreadstart (New ThreadTest (). SHOWMSG));
Threadwithparam.start ("This is a param.");

Use of Parameterizedthreadstart,threadstart, threads thread Pass parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.