<> one , instantiation
<>(1) What is instantiation
* stay Java in , Use defined classes , The process of creating such objects is called “ instantiation ”.
* Instantiation is the process of allocating memory in the heap .
* Only instantiated objects , To access member variables and methods in a class .
<>(2) Instantiated 4 Ways
* ⽤new Create directly
* transfer ⽤clone()⽅ method , enter ⾏ Copy of instance
* send ⽤Java Reflection creation
* Get through deserialization class
[ Deserialization ]: The process of converting a stream into an object
<> two , Process oriented and object oriented
<> Process oriented :
Process oriented performance is higher than object-oriented performance . Because class calls need to be instantiated , Quite expensive , Compare resource consumption , So when performance is the most important consideration , For example, single chip microcomputer , Embedded development ,Linux/Unix Generally, process oriented development is adopted . however , Process oriented is not object-oriented and easy to maintain , Easy reuse , Easy to expand .
<> object-oriented :
Object oriented and easy to maintain , Easy reuse , Easy to expand .
Because object-oriented has encapsulation , inherit , Characteristics of polymorphism , Therefore, a low coupling system can be designed , Make the system more flexible , Easier to maintain . however , Object oriented performance is lower than process oriented performance .
<> three ,JVM
jvm yes Java Virtual machine is running Java Bytecode virtual machine .jvm There are specific implementations for different operating systems .
Java The program has some changes from source code to operation 3 step .
* .java file ( source code ), stay JDK Medium javac Formed after compilation .class file
* .class file (jvm Understandable Java byte ), after jvm Become a binary machine code that the machine can execute
* Binary machine code
<> four , Process and thread
<> process
Process is an execution process of a program , It is the basic unit of system operation program . Dynamic process . The following figure is windows Currently running process .
<> thread
Threads are similar to processes , But threads are smaller units of execution than processes . A process can produce multiple threads during execution . Different from the process, multiple threads of the same kind share the resources of the process heap and method area , But each thread has its own program counter , Virtual machine stack and local method stack .
Technology
Daily Recommendation