Multi-threaded Java programmers architect interview questions and answers to resolve

Here Insert Picture Description
When in the course of our interview Java architect common problem multithreading and concurrency is certainly an essential part. So before the interview we should prepare some questions about the multithreading.
The interviewer just wanted to make sure the interviewer has enough knowledge of Java threads and concurrency, because there are a lot of theoretical knowledge only stay on the surface, after all, or skill is not enough solid. The following is what I like at different times in different locations of Java threads to ask questions, for your reference.

15 multi-threaded Java Architect interview questions and answers to resolve
1) How will you use threaddump? How would you analyze Threaddump?
  In UNIX, you can use the kill-3, then threaddump will print log in the windows you can use "CTRL + Break". Very simple and professional thread interview questions, but if he asks you how to analyze it, it will be very difficult.
  2) Why do we call the start () performs the run () method when the method, why we can not directly call run () method?
  This is another very classic multithreaded java interview questions. This is what I have just started writing multithreaded programs confusing time. Now the problem is usually in a telephone interview or a middle-class Java in the first round of interviews asked. The answer to this question should be like this, when you call the start () method you will create a new thread, and execute code in the run () method inside. But if you just call the run () method, it does not create a new thread does not perform the calling thread code. "The difference between start and run approach" is written before I read this article for more information.
  3) Java How do you wake up in a blocked thread?
  This is a problem on the thread and blocking tricky, it has many solutions. If you encounter a thread blocking IO, and I do not think there is a way to abort the thread. If the thread is blocked because the call to wait (), sleep (), or join () method caused, you can interrupt threads, and to wake it up by throwing InterruptedException. I wrote before "Howtodealwithblockingmethodsinjava" There are a lot of information about the processing thread blocked.
  4) What is the difference in Java CycliBarriar and CountdownLatch?
  This thread problem is mainly used to detect whether you are familiar with the JDK5 and contracting. These two differences are CyclicBarrier reusable obstacle has been passed, but CountdownLatch can not be reused.
  5) What is immutable, it has to write concurrent applications going to help?
  Another multi-threaded classic interview question, not directly related with the thread, but indirectly help a lot. This java interview questions can become very tricky, if he asked you to write an immutable object, or ask you why String is immutable.
  6) What are the common problems you encounter in a multithreaded environment is? How did you solve it?
  Multithreading and concurrent programs often have Memory-interface, race conditions, deadlocks, live locks and hunger encounter. The problem is not enough, if you get it wrong, it will be difficult to find and debug. This is the most based on interviews, rather than Java threading issues based on the actual application.
  7) Java programming will lead to a deadlock in the program, you will be how to solve?
  This is my favorite interview questions Java threads, deadlocks because even when writing multi-threaded programs is very common, but many candidates who can not write deadlockfreecode (no deadlock Code?), They are struggling. Just tell them that you have the resources and the N N threads, and you need all the resources to complete an operation. For simplicity here, n is 2 can be replaced, the larger the data will look more complicated problem. By avoiding deadlocks in Java to get more information about the deadlock.
  8) What is atomic, atomic operations in what is Java?
  Very simple java interview questions thread, the next question is that you need to synchronize an atomic operation.
  9) volatile key in Java What is the role? How to use it? In Java it with synchronized method What is the difference?
  Since Java5 and Java memory model changes, threading issues volatile keyword based more and more popular. Should be ready to answer questions about how to ensure that volatile variable visibility, order and consistency in a concurrent environment.
  10) What is a race condition? How do you identify and resolve the competition?
  This is a multi-threaded appear in the advanced stages of the interview questions. Most interviewers will ask the nearest competitive conditions you encounter, and how did you solve. Some time they will write simple code, and then let you detect race conditions code. Java can refer to the article on the conditions of competition before I posted. In my opinion this is one of the best java interview questions thread, it can detect the exact experience of the candidates to address competition conditions, orwritingcodewhichisfreeofdataraceoranyotherracecondition. The best book in this regard is "ConcurrencypracticesinJava".
  11) There are T1, T2, T3 three threads, how do you ensure T2 after the implementation of execution in T1, T3 after the implementation of execution in T2?
  This question is usually asked thread in the first round or the phone interview stage, the purpose is to detect whether you are familiar with the "join" method. This multi-threaded problem is relatively simple, it can be achieved using the join method.
  12) In Java Interface Lock advantage over synchronized block what it is? You need to implement an efficient caching, which allows multiple users to read, but only allows a user to write, in order to maintain its integrity, what would you do to achieve it?
  lock interface multithreading and concurrent programming biggest advantage is that they provide a lock to read and write, respectively, can meet you write high-performance data structures and obstruction conditional like ConcurrentHashMap. Java threads interview questions will be more and more based on answers to questions of the interviewer. I strongly recommend carefully read Locks, since it is currently a large number of customers for building the electronic trading system of the end-side caching and transaction connected space before you go to multi-threaded interview.
  13) different wait and sleep in java methods?
  Usually often asked in a phone interview Java thread interview questions. The biggest difference is wait while waiting to release the lock, and sleep has been holding the lock. Wait typically used for inter-thread interactions, sleep is often used to pause execution.
  14) implement blocking queue in Java.
  This is a relatively tough interview questions multithreaded, it can achieve many purposes. First, it can detect whether a candidate who can actually write programs in Java threads; second, can detect the candidates' understanding of concurrency scenarios, and you can ask a lot of questions based on this. If he is to achieve blocking queue with a wait () and notify () method, you can ask him to use the latest Java5 in concurrent classes to write again.
  15) written in Java code to solve the producer - consumer issues.
  Very similar to the above problem, but the problem is more classic, there are times when the interview will ask the following questions. How to solve in Java producer - consumer problem, of course, there are many solutions, I have to share a method implemented by blocking queue. Sometimes they'll even ask how to achieve the Dining Philosophers problem.

Architect specializing in Java technology sharing, tease me free to send advance information architect
(Java Architect exchange penguin skirt * / : 445 - 820 - *. 908)

Published an original article · won praise 0 · Views 56

Guess you like

Origin blog.csdn.net/cao123nba/article/details/104001857