Thread means process
Pentium iv 4.3 GHZà43 Lakhs of instructions(cycle ) within 1min Speed
Ctrl+ Alt+ del
Interested in mastering .Net Training? Enroll now for a FREE demo on ".Net Training"
DOS UNIX
given to one app only
System. Threading namespace
Class test {
Public vaid print(){}
}
Syntax:-
Test t = new test();
Thread start ts=new thread start(t.print);
Thread tr=new thread(ts);
Start the thread Tr. start()
A program to execute two for loops simultaneously
Open console application project Using system. Threading;
code in GD Class test
{
Public static vold p1()
{
For (int i=1; i<=10;i++)
{
Console. write(I+””);
Thread . sleep(500);
}//for
}
//p1
Public static void p2()
{
For(int k=11;k<20;k++)
{
Console. write link(k);
Thread. sleep(500)
//500 millisec
}//for
}
//p2 }//test
Code for the main method:-
Thread start ts1=new thread start (Test.p1)
Thread start ts2=new thread start (Test.p2)
Thread t1=new thread (ts1)
Thread t2=new thread (ts1):
//here
ts1 T1.start() T2.start() Console.Read key();
T1.suspend(); Console. Read key();
T1.Resume(); Console. Read key ();
o/p : 112233----2020
1.Thread synchronization is the concept of allowing only one thread at a time into one process
2.It process is busy, threads need to wait in the queue
3.Waiting threads will be executed based on priority
OBS:
5.The code which is written in between wait one()and release mutex()is called a synchronized code.
{
Console. write(“ALL”);
Console. write(“THE”);
Console. write(“Best”);
}
open console application project Using system. Threading;
Class program
{
Static mutex m = new mutex();
Class test
{
Public static void print()
{
wait one();
console. write(“ALL”);
Thread. sleep(1000);
Consote. write(“THE”);
Thread .sleep(1000);
Console. write(“BEST”);
Thread. sleep(1000);
Console. Write line();
//for new line Thread. sleep(1000);
Release mutex();
}//print }//test
Code for the main method:-
{
Thread start ts=new thread start(test. print);
Thread start t1=new thread (ts);
Thread start t2=new thread (ts);
Thread start t3=new thread (ts);
T1.Start(); T2.Start();
T3.Start();
Console. Read key();
}
Pointers:-
Why we use pointers? For fast accessing Fig(a) Accessing ’i’ value is fast when compared to the pointer variable, but it is not in this case fast. Char*p
2B Double*p
Logic is m/c of o/s they are unmanaged code.
The size of the pointers varies or dependent on the o/s, so they are unmanaged code, so c#.net only supports pointers but not implemented.
Unsafe is a keyword Pointers logic must be the part of the unsafe block only Pointer size varies from o/s to o/s Generally o/s are divided into 3 types
Unmanaged code is not all recommended In c# .net it we want to use in c# by using un sate keyword
Ex:-
Place a button on the form
{
Un sate { Int iz 90; Int*p; P=&I;
Int k; K=*p**p; MBS(K+””);
}
By pressing f5 it gives a warning that you are using un state code. Please inform to CLR to execute unsafe code.
Go to project
properties
buildàCheck Menu “Allow un sate code” Check Box Execute the project Inter+ view
Internal look-Behavior
subject
time sense
Body language
confidence
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.