Small problem Small Catechism of the interview process, I am asking you ^ _ ^

1) 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?

( Pulled left GitHub link, you need access to relevant content such as interviews can find their own )
https://github.com/xiangjiana/Android-MS

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.

2) Lock in Java interfaces 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 like ConcurrentHashMapblocking such a high-performance data structures and conditional. 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.

3) 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.

4) 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 wait()and notify()methods to achieve blocking queue, you can ask him to use the latest in Java 5 concurrent class to write again.

5) 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.

6) 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 deadlock free code (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.

7) 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.

8) volatile key in Java What is the role? How to use it? In Java it with synchronized method What is the difference?

Since Java 5 and Java memory model changes, threading issues volatile keyword based more and more popular. We should be ready to answer questions about how to ensure that volatile variable visibility In a concurrent environment.

9) 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 candidate to address the conditions of competition experience, or writing code which is free of data race or anyother race condition. About the best book in this regard "Concurrency practices in Java".

10) How would you use threaddump? How would you analyze Thread dump?

In UNIX, you can use kill -3, then thread dump 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.

11) 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 start()upon the way you will create a new thread, and execute code in the run () method inside. But if you call the direct run()method, it does not create a new thread does not perform the calling thread code.

12) 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 because the call wait(), sleep()or a join()method which led to blocking, you can interrupt threads, and by throwing InterruptedExceptionto wake it up.

13) 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 CountdownLatchcan not be reused.

14) 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.

15) 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.

Easily leave GitHub link, you need access to relevant content such as interviews can find their own
https://github.com/xiangjiana/Android-MS

Guess you like

Origin blog.51cto.com/14541311/2458854