2018 Java Thread Top interview questions, how much do you know?

Source: Internet
Author: User
Tags thread class

Is it difficult or difficult to interview? It depends on the interviewer's background (gas field + skills), mentality and cognitive and communication skills. Interview can be understood as a chat and negotiation, in the process of psychological, ideological collision and game. In fact, you just need to figure out a logic: "Why does the interviewer ask?" What answer does he want to hear? "Then the targeted preparation and answer on the line, without him."

Whether you are a new programmer or a veteran, you must have encountered a thread-related problem in your interview. An important feature of the Java language is the built-in support for concurrency, which makes Java popular with businesses and programmers. Most well-paid Java development positions require developers to be proficient in multithreaded technology and have extensive experience in Java program development, debugging, and optimization, so thread-related issues are often mentioned in interviews.
In a typical Java interview, the interviewer asks the basic concept of the thread

such as: Why do you need to use threads, how to create threads, how to create threads better (such as inheriting the thread class or calling the Runnable interface), and then gradually ask about concurrency problems like the Java memory model encountered in the process of Java concurrent programming, JDK1.5 introduces higher-order concurrency tools, common design patterns for concurrent programming, classic multithreading issues such as producer consumers, philosophers dining, reader-readers, or simple bounded buffer problems. Just knowing the basic concept of threading is far from enough, you must know how to deal with the concurrency problems such as deadlock, race condition, memory conflict and line Cheng. With these tips, you can easily handle multithreading and concurrent interviews.
It's normal for many Java programmers to go to the interview before the interview.

Because collecting face questions and exercises took time, I collected 50 hot questions from many interviewers about Java multithreading and concurrency.

1. What is a thread?

2. What is thread safety and thread insecurity?

3. What is spin lock?

4. What is the Java memory model?

5. What is CAS?

6, what is optimistic lock and pessimistic lock?

7. What is Aqs?

8. What is atomic operation? What are the atomic classes (atomic classes) in the Java Concurrency API?

9. What is the executors framework?

10. What is a blocking queue? How do I use a blocking queue to implement a producer-consumer model?

11. What is callable and future?

12. What is Futuretask?

13. What are the implementations of synchronous containers and concurrent containers?

14, what is multi-threaded? Advantages and Disadvantages

15, what is multi-threaded context switch?

16, threadlocal design concept and role?

17, ThreadPool (thread pool) usage and advantages?

18, concurrent bag of other things: Arrayblockingqueue, Countdownlatch and so on.

19, the difference between synchronized and reentrantlock?

20. What is the role of semaphore?

21. What is the lock interface (lock interface) in the Java Concurrency API? What are the advantages of comparing synchronization?

22, Hashtable the size () method is clearly only one statement "return count", why do you want to synchronize?

23. What is the concurrency level of concurrenthashmap?

24, the use of Reentrantreadwritelock read and write lock?

25, Cyclicbarrier and Countdownlatch usage and difference?

26, Locksupport tools?

27, condition interface and its realization principle?

28, the understanding of Fork/join framework?

29. What is the difference between wait () and sleep ()?

30. Five states of the thread (five states, create, ready, run, block, and die)?

31. What is the difference between the start () method and the Run () method?

32. What is the difference between runnable interface and callable interface?

33, the role of volatile keywords?

34. How do I get to the thread dump file in Java?

35. What is the difference between threads and processes?

36, there are several ways to implement the thread (four kinds)?

37, high concurrency, short task execution time how to use the thread pool? How does a business with a low concurrency and long task execution use the thread pool? How does a business with high concurrency and long business execution use the thread pool?

38. What happens if the thread pool queue is full when you submit a task?

39, Lock Level: Method Lock, Object lock, class lock?

40. What happens if a thread inside a synchronization block throws an exception?

41. What is the difference between concurrent programming (concurrency) parallel programming (parallellism)?

42, how to ensure that the results of multi-threaded i++ correct?

43. What happens to a thread if a run-time exception occurs?

44. How do I share data between two threads?

45. What is the role of the producer consumer model?

46, how to wake up a blocked thread?

47. What is the thread scheduling algorithm used in Java?

48. Thread safety in single-case mode?

49, the Thread class construction method, static block is called by which thread?

50, synchronous method and synchronization block, which is the better choice?

51, how to detect deadlocks? How to prevent deadlocks?

Need to answer the above questions, follow me short message reply Java thread interview free access.

2018 Java Thread Top interview questions, how much do you know?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.