C # multi-thread Data Transmission

Source: Internet
Author: User

Using system; <br/> using system. collections. generic; <br/> using system. LINQ; <br/> using system. text; <br/> using system. threading; </P> <p> namespace multithreading <br/>{< br/> class thread data transmission <br/>{< br/> Public static void main () <br/> {<br/> // console. writeline ("main thread output"); </P> <p> // thread T1 = new thread (run); <br/> // t1.name = "thread 1 "; <br/> // t1.start (); </P> <p> // thread t2 = new thread (run ); <br/> // t2.name = "thread 2"; <br/> // t2.start (); <br/> data Data = new data (); <br/> data. messages = "I have never said any lines in my mind, so I am afraid you can't take such a fight"; <br/> thread T1 = new thread (threadmainwithparams); <br/> t1.start (data ); </P> <p> console. readline (); <br/>}</P> <p> public struct data <br/>{< br/> Public String messages; <br/>}</P> <p> Public static void threadmainwithparams (Object O) <br/>{< br/> data Data = (data) O; <br/> console. writeline ("content {0}", Data. messages); <br/>}</P> <p> Public static void run () <br/>{< br/> console. writeline ("thread name {0}", thread. currentthread. name); <br/>}< br/>}

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.