object[] Parameters = new Object[2];
Parameters[0] = 5;
PARAMETERS[1] = 3;
Object returnvalue = Powinfo.invoke (obj, parameters);
Console.WriteLine ("5 to" 3rd power is {0}, returnvalue);
Thread:
Create Implicit Threads
Using System.Threading
Thread threadone = new Thread (new ThreadStart (Countup));
Thread threadtwo = new Thread (new ThreadStart (Countup));
Threadone.name = "Thread One";
Threadtwo.name = "Thread two";
Threadone.start ();
Threadtwo.start ();
Joining & Killing Threads
Join two threads in current Threa
Threadone.start ();
Threadtwo.start ();
Threadone.join ();
Threadtwo.join ();
This'll print, after two above two threads ends
Console.WriteLine ("The Other Threads Done");
Sleep (Millisenconds)
Threadone.sleep (1);
Threadone.abort ();
Synchronization:
1. No conflict between threads
Interlocked. Increment (ref synchvalue);
2. Lock method, this would block the other thread is it enter into it
Lock (This)
{
int temp = Synchvalue;
temp++;
Thread.Sleep (2);
Synchvalue = temp;
Synchvalue = temp;
Console.WriteLine (' {0} Count up: {1} ',
Thread.CurrentThread.Name,
Synchvalue);
}
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.