Profile Picture
IT Made Easy
The site provides some rough IT Notes that make your life easier. The site currently has notes on HTML, CSS, Regex, OOPS, JS, JQuery, PHP, Java, ASP.NET, C#, Database, Linux, URL Rewrite, SEO, Project Management and Hosting. Please do share this site if you like.

Threading

Next
Next
  • System.Threading
  • Thread t = new Thread(fn);   //Here in actuality we pass delegate
  • A threads IsAlive property returns true, until the point where the thread ends
  • A separate copy of the local variable is created on each thread's memory stack
  • Threads share data if they have a common reference to the same object instance
  • Static fields offer another way to share data between threads
  • Thread safety where output is deterministic
  • The remedy is to obtain an exclusive lock while reading and writing to the common field
  • When two threads simultaneously contend a lock (in this case, locker), one thread waits, or blocks, until the lock becomes available
  • So critical section is entered only one at a time
  • While waiting on a Sleep (the current thread waits for specific time) or Join (other threads wait), a thread is blocked and so does not consume CPU resources.
  • Join returns true if the thread ended or false if it timed out
  • Sleep(0) relinquishes the threads current time slice immediately to CPU and Yield function to processes on same processor

IT Notes

by VinodSebastian



IT Downloads


Catalogue