Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I wonder what sort of interview questions were asked to a senior developer or technical consultant on multithreading.

Kindly provide me some of the interview questions which were asked in the interview on multithreading if possible kindly put the scenario based questions with some theoretical questions. As I came to know after disscusion with some of the people that some time interviewer might give you a scenario and ask you to implement it?

@ Kindly add the specific questions which you have ever faced or asked to the other person in the interview other than only mentioning the concepts because people go through the concepts and still find it difficult to handle the interview questions.so any effort to add the specific question could actually help person to get a head start for the d-day

share

migrated from stackoverflow.com Feb 20 '11 at 20:39

This question came from our site for professional and enthusiast programmers.

locked by ChrisF Mar 13 '12 at 11:02

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

    
In reality this should probably be voted to close/deleted moved to a blog. –  sixlettervariables Feb 20 '11 at 17:23
comments disabled on deleted / locked posts

5 Answers

I might ask the candidate to describe at least 2 or 3 different ways to create multi-threaded applications in C#.

  • Explicit use of Thread class

  • Threadpool

  • Task Parallel Library

  • Action class with lambda functions

  • BeginInvoke

  • BackgroundWorker

I would also inquire how one might end up with an application that is multi-threaded without ever explicitly creating a thread.

  • Event handlers can run in another thread (SerialPort.DataReceived comes to mind, as does one or two of the three Timers in .Net).

You may also wish to talk about methods for creating re-entrant code.

  • lock

  • Monitor.Wait and Monitor.Pulse

  • ManualResetEvent

  • static classes/methods

Some more information could come from a post I wrote here.

Finally, I might ask for experiences where these lessons have been learned instead of just a brain dump from a book. A senior developer will have plenty experiences which should provide insight on their discovery and problem solving capabilities.

share
    
@Nate:Thanks for you answer to the post but it would be great that if you add some specific questions on the concepts what you mentioned? –  Mohit Bhandari Feb 20 '11 at 19:00
1  
I thought I did. There's 2 or 3 methods of accomplishing multi-threaded applications, how one might implement re-entrant code, an inquiry into the candidate's understanding of the implicit multi-threaded nature of .Net events, and finally some examples of experiences the developer has had. Just turn those sentences and concepts into a question. –  Nate Feb 20 '11 at 19:14
    
While good questions one problem is that they only describe different techniques. I'd be much more concerned in finding out if they truly understand different concurrency and parallelism scenarios. Libraries comes and goes, but the underlying concepts remain. –  konrad May 18 '11 at 14:10
add comment

In addition to all other answers I would also present the candidate with a couple of thread examples and make him point out where the problems could arise.

Some examples would include race conditions, interlocks or having him face converting a problem from single threaded to multithreaded. I specially like to follow that last one with a review of his design, by letting him explain why, how and how much performance increase would he improve.

share
    
Good idea, but can you at least outline a concrete example? All I the examples I can come up with are either way too long (spanning multiple pages) or or way too simple (two locks, acquired in the wrong order at one point) –  nikie Feb 21 '11 at 6:35
add comment

One of my favourite questions:

  1. How can you create responsive UI without using threads. Expected answer: By splitting work in small pieces and queuing them on the message loop of the UI. (Eric Lippert has a good explaination on how to do that http://blogs.msdn.com/b/ericlippert/archive/2010/10/25/continuation-passing-style-revisited-part-three-musings-about-coroutines.aspx )

An interesting question not currently not listed in another answer:

  1. Explain work stealing in TPL. How it works and why? Expected answer: Explain how the core that owns the queue extracts items on one side while a core that does not own the queue "steals" from the other side in order to preserve CPU cache lines.
share
    
What is the/an answer to the first question? –  RichK Feb 20 '11 at 17:37
    
uhm, don't do anything that takes longer than a couple of milliseconds? Really tell us! –  gjvdkamp Feb 20 '11 at 18:05
    
@Stilgar Could you elaborate a bit on your first question?How to create responsive UI's without creating threads? –  Mohit Bhandari Feb 20 '11 at 18:47
    
@Stiglar Could you add a particular question which you have faced or asked to person for "Creating responsive UI"? –  Mohit Bhandari Feb 20 '11 at 19:01
    
I've added explaination to the answer. Basically the idea is splitting the work in small pieces as gjvdkamp suggested. Eric Lippert has a good explaination on his blog that points out that multitasking is possible on a single core machine, therefore a way exists to do responsive UI with a single thread. This model is particularly useful when the major blocking comes from IO operations. Basically you only need to check if the IO operation has completed. –  Stilgar Feb 20 '11 at 19:04
show 6 more comments

I always liked this matrix: http://www.indiangeek.net/wp-content/uploads/Programmer%20competency%20matrix.htm

It doesn't provide you a ready box of questions but it does provide a pretty exhaustive set of fields from where you could (should) pick questions to rank an applicant.

GJ

share
    
@gjvdkamp- the link is very good...for interviewer as well as interviewee, the matrix can serve as a good checklist. –  ViSu Jan 3 '12 at 2:25
add comment

A good method I have found is to create a few mock classes that would be in need of various forms of multithreading, like using Invoke, WaitHandles, Semiphores etc then print the clases out and discuss the options with the candidate. It gives the interviewee more feedback on how the candidate thinks and gives the candidate to offer in references to previous projects etc.

share
add comment