What is a deadlock?
The so-called deadlock: refers to two or more than two processes in the course of execution, because of competing resources or due to the communication between each other caused by a blocking phenomenon, if there is no external force, they will not be able to proceed. At this point the system is in a deadlock state or the system generates a deadlock, and these processes, which are always waiting on each other, are called deadlock processes.
What is the use of static in Android
member variables and member methods that are modified by static are independent of any object of the class. That is, it does not depend on class-specific instances and is shared by all instances of the class. As long as this class is loaded, the Java virtual machine can find them based on the class name in the method area of the run-time data area. Therefore, a static object can be accessed before any of its objects are created, without referencing any objects.
A static code block is represented by a statically decorated code block, which is executed when the Java Virtual Machine (JVM) loads the class.
Deep understanding of why inner classes can access members of external classes in Java
An inner class is a class that is defined inside a class. There are two cases of a class that is defined inside a class: one that is modified by the static keyword, called a static inner class, and one that is not modified by the static keyword, which is an ordinary inner class.
- The creation of an inner class object depends on the outer class object;
- The inner class object holds a reference to an external class object.
Depth Reason:
- The compiler automatically adds a member variable to the inner class that has the same type as the outer class, which is a reference to the Outer class object;
- The compiler automatically adds a parameter to the construction method of the inner class, which is the type of the outer class, which is used within the constructor method to assign a value to the member variable added in 1;
- When the constructor of an inner class is called to initialize an inner class object, a reference to the external class is passed in by default.
The difference between a process and a thread
A thread is an execution unit within a process and a scheduler within a process.
Differences from the process:
(1) Address space: An execution unit within a process; The process has at least one thread; they share the address space of the process, and the process has its own independent address space;
(2) Resource ownership: A process is a resource that is allocated and owned by a thread in a process that shares the resources of the process
(3) The thread is the basic unit of the processor dispatch, but the process is not.
4) Both can be executed concurrently.
Processes and threads are the basic units that the operating system realizes, and the system uses this basic unit to realize the concurrency of the system to the application. The difference between a process and a thread is:
In short, a program has at least one process, and a process has at least one thread.
The thread's dividing scale is smaller than the process, which makes the multi-thread procedure high concurrency.
In addition, the process has a separate memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation.
Threads are still different from the process during execution. Each separate thread has a program run entry, sequence of sequence execution, and exit of the program. However, threads cannot be executed independently, and must be dependent on the application, which provides multiple threads of execution control.
From a logical point of view, the meaning of multithreading is that in an application, multiple execution parts can be executed concurrently. However, the operating system does not consider multiple threads as separate applications to implement scheduling and management of processes and resource allocation. This is the important difference between processes and threads.
A process is a program with a certain independent function about a single run activity on a data set, a process that is an independent unit of the system's resource allocation and scheduling.
A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch, which is a smaller unit that can run independently than a process. The thread itself basically does not own the system resources, only has a point in the operation of the necessary resources (such as program counters, a set of registers and stacks), However, it can share all of the resources owned by the process with other threads that belong to one process.
One thread can create and revoke another thread, and can execute concurrently between multiple threads in the same process.
The difference between HashMap and hasptable
First, inheritance is different.
public class Hashtable extends Dictionary implements Mappublic class HashMap extends AbstractMap implements Map
Second
The methods in Hashtable are synchronous, and the methods in HashMap are not synchronized by default. In the context of multi-threaded concurrency, you can use Hashtable directly, but to use hashmap, you need to increase the synchronization process.
Third
In Hashtable, both key and value do not allow null values.
In HashMap, NULL can be used as a key with only one key, and one or more keys can have a value of NULL. When the Get () method returns a null value, it can indicate that the key is not in the HashMap, or that the value corresponding to the key is null. Therefore, the get () method cannot be used in HashMap to determine whether a key exists in HashMap and should be judged by the ContainsKey () method.
Four, the internal implementation of the two traversal methods is different.
Hashtable and HashMap all use the Iterator. For historical reasons, Hashtable also used the enumeration approach.
Fifth
Hash values are used differently, Hashtable directly using the object's hashcode. The hash value is recalculated by the HashMap.
Sixth
Hashtable and hashmap their two internal implementations of the array's initial size and the way the capacity is expanded. The default size of the hash array in Hashtable is 11, and the increment is old*2+1. The default size of the hash array in HashMap is 16, and must be a 2 index.
Reference:
The difference between HashMap and Hashtable
What are the ways to communicate between Android processes
Android Inter-process communication
Android Binder and interprocess communication
In-depth analysis of aidl principles
6 Ways to Android IPC
Android IPC Process Communication--messager mode
Which methods are loaded by Android asynchronously
Asynctask, Handlerthread, Activity.runonuithread (Runnable)
How to load an Android image asynchronously
A detailed description of the use of Asynctask in Android
Android Basics: Asynchronous Tasks (Asynctask)
Android sync mechanism, synchronized
Java Synchronization mechanism: synchronized
Java Synchronized Detailed
Why design patterns are used
Why we need to learn (design) patterns
Knowledge of design pattern discussion
How to use the design pattern correctly
Static methods can use non-static variables, the static keyword
If you want a property in an object to be shared by all objects, you must declare it as a static property, and if a method in a class wants to be called by a class, you can declare it as a static method
Properties declared with static become global (also known as static properties, class properties)
Areas of memory commonly used in Java
- Stack memory space: Saves all object names (more precisely the address that references the heap memory space)
- Heap memory space: Saves the specific property content of each object
- Global Data area: Saving properties of static type
- Global Code Area: Save All method definitions
Methods that use static declarations are called class methods
A method of a non-static declaration can invoke a property or method of a static declaration, but the method of static declaration cannot invoke a property or method declared by a non-static type. Static cannot invoke any non-static content, because all properties and methods in the program must be called after the object has opened up heap memory, and methods of the static type can be called by the class name when the object is not instantiated.
The summary of NetEase electric face problem