Java Interview 11-15

Source: Internet
Author: User

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

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.