Multithreading Questions and Answers

By
1. ) What is thread ?                                                                                                              
A thread is basically a separate sequence of instruction designed to performing a " specific task" in the program.

2. ) What is Multithreading in c# ?                                                                                   
Performing multiple task at same time during the execution of a program,is known as multithreading.

3. ) What is the Namespace used for multithreading in c# ?                                      
using System.Threading;

4. ) What are the advantage of multithreading in c# ?                                                 
There are two main  advantage to use of multithreading in c#.
  • Optimize the use of computer resources such as memory.
  • Save time
5. ) What are the classes used in System.Threading Namespace ?                           
  • Thread 
  • Thread Pool
  • Monitor
  • Mutex
6. ) What is the use of Thread class in c#?                                                                    
The Thread class is used to perform tasks such as creating and setting the priority of a thread.

7. ) What are the main properties of thread class?                                                      
  • Priority
  • Thread State
  • IsAlive
  • Current thread
  • Name    etc.
8. ) What are the methods used in thread class?                                                       
  • Join
  • Resume
  • sleep
  • Spin Wait
  • Suspended
  • Start
  • Interrupt
9. ) What is the Thread Pool class in c#?                                                                        
The Thread Pool class is used,to perform task such as processing of asynchronous i/o and waiting on behalf of another thread.

10. ) What are the method used in Thread Pool class ?                                                
  • Gettype
  • Equals
  • SetMaxThreads
  • QueueUserWorkItem
11. ) What is monitor class in c# ?                                                                                     
The Monitor class is used to access an object by granting a lock for the object to a single thread.

12. ) What are the methods used in monitor class  ?                                                     
  • Enter
  • Exit
  • TryEnter
  • Wait
  • GetType
13. ) What is Mutex class in c# ?                                                                                        
A Mutex is used ,to perform interprocess  synchronization and a thread to have exclusive access to shared resources.

14. ) What are the methods used in Mutex class ?                                                         
  • Equals
  • close
  • OpenExisting
  • SetAccessControl
  • Release Mutex
15. ) What are the syntax for creating and starting a thread in c# ?                         
First define a delegate:-
Public delegate void start_thread();
Create a new thread:-
Thread thread_name = new Thread(new start_thread(method_name));
More Details ...

16. ) Can we create timer in threading ?                                                                           
Yes.

17. ) How can we scheduled a thread in c# ?                                                                   
We can scheduled the  thread with the help of priority property of the Thread class. 

18. ) What are the priority value used for scheduling a thread in c# ?                    
  • Highest
  • Normal
  • AboveNormal
  • BelowNormal
  • Lowest

19. ) What are the two types of thread in c# ?                                                               
  • Foreground thread
  • Background thread
20 .) What is difference between Foreground and Background thread ?                 

0 comments:

Post a comment

Powered by Blogger.