11, class loading process, how to get the current object ClassLoader
The process of class loading is divided into: load, connect, initialize, use, and unload. Where connectivity can be divided into: verification, preparation and resolution
Gets the classloader of the current object through the following code:
This.getclass (). getClassLoader () //Gets the class object of the current object, and then calls getClassLoader
Class Loaders can perform class-level partitioning, OSGi, hot deployment, and code encryption. So how do users customize the ClassLoader?
To create a user's own classloader, simply extend the Java.lang.ClassLoader class and overwrite its findclass (String name) method, which specifies the name of the class based on the parameter and returns a reference to the corresponding class object.
Findclass protected class<?> Findclass (String name) throws ClassNotFoundException
Finds a class using the specified binary name. This method should be overridden by the implementation of the ClassLoader, which loads the class according to the delegate model. This method is called by the LoadClass method after the requested class is checked by the parent class loader. The default implementation throws a ClassNotFoundException.
12, about the CONCURRENTHASHMAP related issues
(1) Concurrenthashmap Lock segmentation Technology.
(2) Concurrenthashmap read whether to lock, why.
(3) The Concurrenthashmap iterator is a strongly consistent iterator or a weakly consistent iterator.
13, if there are Thread1, Thread2, Thread3, Thread4 four threads respectively statistics C, D, E, f four disk size, all threads are counted to THREAD5 thread to do summary, how should be realized?
The separate computing tasks are included in a single unit of work, eliminating the need to start new threads for each unit. It is often more efficient to handle multithreaded code. Because you do not have to start the thread thread separately for each compute unit. The thread that executes the code is reused.
(1) Tasks
Callable represents a piece of code that can be called and returned results
The future interface is used to represent the asynchronous task, which is the result of a task that has not yet been completed. The main methods are get (), Cancel (), and Isdone ()
Futuretask is a common implementation class for the future interface
(2) The performer obtains one of the many performers through the factory method of the Executors class
Java interview 11-15