Untitled
unknown
plain_text
2 years ago
981 B
2
Indexable
using System; using System.Threading; class Program { static void Main(string[] args) { long sum1 = 0, sum2 = 0, sum3 = 0; AutoResetEvent t1Event = new AutoResetEvent(false); AutoResetEvent t2Event = new AutoResetEvent(false); AutoResetEvent t3Event = new AutoResetEvent(false); Thread t1 = new Thread(() => { for (int i = 1; i <= 1000; i++) { sum1 += i * i; } t1Event.Set(); }); Thread t2 = new Thread(() => { for (int i = 1001; i <= 2000; i++) { sum2 += i * i; } t2Event.Set(); }); Thread t3 = new Thread(() => { for (int i = 2001; i <= 3000; i++) { sum3 += i * i; } t3Event.Set(); }); t1.Start(); t2.Start(); t
Editor is loading...