User FAQs
If you have a question, please send it to us.
1) What is Multi-Threading ?
In a single threaded application there is only one active thread.
In a multi-threaded application you can have two (or more) active threads.
This allows different tasks to be carried out in parallel.
The advantage of a divide and conquer strategy is that it will improve performance.
2) What is the difference between a Process and a Thread ?
Processes are independent, threads are not independent.
Switching between processes is slower than switching between threads.
A process has its own address space, all the threads within a single process all share the same address space.
3) Can you describe the different Thread States ?
Unstarted -
Running -
SleepWaitJoin -
Suspended -
Stopped -
4) What is the difference between a Background Thread and a Foreground Thread ?
Any threads that are explicitly created are foreground threads.
A foreground thread runs indefinitely and will keep the application alive.
A background thread terminates when the foreground thread is stopped and will not keep the application alive.
5) What is displayed when this code runs ?
public main()
{
Method1()
MessageBox.Show("Two");
}
public async void Method1()
{
thread.wait(10);
MessageBox.Show("One");
}
The Method1 is executed on a different thread and this message box will only be displayed after the 10 seconds.
"Two"
"One"
6) What does the ThreadStatic attribute do ?
System.ThreadStaticAttribute
This is used to indicate a variable is thread safe.
A static variable is not shared between threads.
Each executing thread will have a separate instance of the field and will independently set and get values for that variables.
If the variable is accessed on a different thread, it will contain a different value.
7) What is the Task Parallel Library ?
This replaces the earlier Processor and Thread classes with a new class called Task.
The System.Threading.Tasks namespace has been designed for executing multi-threaded applications on machines that have multiple core processors.
The new Task class has a higher level of abstraction than the Thread.
8) What does the async keyword do ?
Introduced in C# 5.0 (.NET 4.5).
9) What is the difference between Threading.Timer and Timers.Timer ?
They were both added in .NET 1.1
10) When would you use the lock statement ?
Use the lock statement in C# and the SyncLock statement in Visual Basic to synchronize access to a shared resource instead of using the Monitor class directly.
11) What is the Monitor class ?
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext