Interview answers verified by specialists.

Find interview questions and answers on this website:

See right interview answers on 30 common job interview questions

How do I spawn a thread?

We need to create an instance of a System.Threading.Thread object and passing it an instance of a ThreadStart delegate that will be executed on the new thread.

For example: 

class MyDemoThread 
public MyDemoThread( string initData ) 
m_data = initData; 
m_thread = new Thread( new ThreadStart(ThreadMain) ); 
} // ThreadMain() is executed on the new thread. 
private void ThreadMain() 
Console.WriteLine( m_data ); 
public void WaitUntilFinished() 
private Thread m_thread; 
private string m_data; 
In this case creating an instance of the MyDemoThread class is sufficient to spawn the thread and execute the MyDemoThread.ThreadMain() method: 
MyDemoThread t = new MyDemoThread( "Hello, world." ); 

Do you know that?

41.9% of freelancers get the bulk of their training in university/colledge Next


Fast Payments
Payoneer sing up to get free