Package
Compilation format javac-d. **.java
Access between packages
Class not found: Class name is wrong, package name. Class Name
Package does not exist: Specify Classpath
Class for other packages cannot be accessed: permissions public
Protected
Package Imports Import
Principle: Which class to use, and which class to import
Jar Package
JAR-CF Aha.jar.
Specify the class file in Classpath,jar for the jar to run directly
Multithreading
Procedure in progress in progress
A control unit in the thread process that is responsible for program execution
Pros and cons
Run simultaneously
Thread Multi-efficiency low
Multithreading creation-inheriting the thread class
Create thread mode One: Inherit the thread class
1. Define class and Inherit
2. Override the Run method in the thread class
3. Creating Threads
4. Start thread
Defined in the Run method is the task code that the thread will run
Because you are running a custom task code, you need to override the
Method thread name in the thread class
CurrentThread (). GetName ();
Graphic
1 classthreaddemo{2 Public Static voidMain (string[] args) {3Demo A =NewDemo ("Xiao Qiang");4Demo B =NewDemo ("Wancai");5 A.start ();6 B.start ();7 for(intx=0;x<5;x++){8System.out.println (",,, x=" +x+ "... name:" +Thread.CurrentThread (). GetName ());9 }Ten } One } A - classDemoextendsthread{ - PrivateString name; the Demo (String name) { - Super(); - This. Name =name; - } + Demo () {} - + Public voidrun () { A for(intx=0;x<10;x++){ atSystem.out.println (",,, x=" +x+ "... name:" +Thread.CurrentThread (). GetName ()); - } - } -}
Java Day 12