Common java face questions small ape laps summary, you learn it?

June of this year went to, but also the annual graduation season, but you're really ready for it? . Many graduates, how to make yourself stand out in this crowd it? Then you need to do extremely prepared, do not fight the battle unprepared, following a small circle java ape lecturer has come up with a common java face questions, want to help your interview.

    1.list stored string can be repeated, how to remove a string

Call the iterator associated method to delete

Pour delete, delete the lead to prevent an array of positive sequence rearrangements, index skip array elements problem

    Why not lock read 2.concurrenthashmap

jdk1.7

1) HashEntry the key, hash, next are the final type, only the header insertion, deletion node

2) HashEntry class field value is declared as volatile type

3) not allowed as keys and null values, when the reader thread reads the value field is null a HashEntry, they know had a conflict - a phenomenon occurred reordering (put the new value set bytecode objects reordering the instruction), the need to re-read the lock value value

4) volatile memory variable count visibility coordination between the reader thread, modify count, a read operation after a write operation before a read count, a read modify write operation of the operation principle according to happen-before transmissibility can be seen

jdk1.8

1) Node of val and next are volatile type

2) tabAt and unsafe operation corresponding casTabAt realized volatile semantics

    3.ContextClassLoader (thread context class loader) effect

Parents delegate mechanism across class loader to load classes, such as serviceloader achieve

Thread context class using the class loader loads, need be taken to ensure the plurality of class loaders communication between threads should be the same, because of preventing different types of class loaders results in translation exception (a ClassCastException)

    4. How to end a thread has been running

Use the exit sign, this flag variable is visible to multiple threads

Use interrupt, in combination isInterrupted () using

    5. How to get the results from not block FutureTask

get (longtimeout, TimeUnitunit), the timeout is returned

Polling, first () to determine whether to end by isDone, and then call the get ()

    6. thread pool process from start to work

When just created, there is no thread

When you add a task calling execute ():

1) If the number of threads running less than core parameters corePoolSize, continue to create a thread to run this task

2) Otherwise, if the number of running threads is greater than or equal to corePoolSize, the task will be added to the blocking queue

3) Otherwise, if the queue is full, while the number of threads that are running less than core parameters maximumPoolSize, continue to create a thread to run this task

4) Otherwise, if the queue is full, while the number of threads is greater than or equal maximumPoolSize running, according to the set policy processing refuse

5) to complete a task, continue to remove a tasking

6) do not continue processing task, the thread is interrupted or the thread pool is closed, the thread exits execution, if the thread pool is closed, the thread end

7) Otherwise, determine the number of threads running thread pool is greater than the core number of threads, if so, the end of the thread, or the thread blocked. Therefore the thread pool to perform all tasks completed, continue to exist in the thread pool size corePoolSize

    7. The blocking queue and poll difference BlockingQueuetake

poll (time): BlockingQueue removed in the first row in the object, if not taken immediately, you can wait a predetermined period of time parameter, taking less time to return null

take (): Remove BlockingQueue in first place in the object, if BlockingQueue is empty, block until BlockingQueue new objects are added

Small ape circle lecturer summary java face questions on here, see the article of little friends have to take a look at this face questions are summarized in the intentions of the teacher, the last wish all students to find a satisfying job, refueling !

Guess you like

Origin www.cnblogs.com/xiaoyuanquan/p/10984368.html