8-2 Advanced Basics Summary multi-threading, Network programming, Java Basics Supplement

Source: Internet
Author: User

A program in the process of running a process, a process may be used to one to multiple threads, and Java often used to multi-threading, such as Debug. each call method uses Multithreading. in java, you can create a thread with a subclass of thread, Then the Run method inside the subclass executes the code we want to Program. you can also create and override the Run method directly in the anonymous subclass.

Synchronized synchronous lock Mechanism. An object has only one lock, and only one thread can hold the lock at the same time.

The lock requested by the Non-static synchronization method is the lock of the Class's current object, and the lock requested by the static synchronization method is the class Object's Lock. After the synchronization method is executed, the lock is returned to the system//

All threads that need to be synchronized must request a lock on the same object, and the synchronization lock mechanism will fail when a different lock is requested or if the thread is not using synchronized.//

Wait (); Notify (); must be used in conjunction with Synchronized.

ip/a computer corresponding to an IP address, you can find the corresponding address in the network Connection. Domain Name: localhost//represents a local. each domain name corresponds to an IP address. the domain name is good for ip.

PORT/TCP protocol/socket programming/client, Server side, using socket step 1) to establish socket connection 2) get socket input/output stream. 3) Exchange communication using IO stream, 4) shutdown IO stream close socket connection

UDP Connection. to use Datagramsocket (port 1) to create the Send Side. Then use Datagrampacket (byte[],byte[].length,ip address, port number 2) send (packet);

Datagramsocket (the Port corresponds to the Send end). Then use Datagrampacket (byte[],byte[].length)/.length for the true length of the data =packet.getlength ()//receive (packet);

Binary every 2 in 1. The n-0/1/10/11/100/101/110/111/1000/1001/1010 of the decimal 2 can be expressed as 2 followed by N 0//2 2 times 4 = 100 2 is 3 = 8 ...

The character encoding ASC corresponds to a Byte. Including the letter A97 A 65 is commonly used for encoding utf-8.gb-2312 GBK.

Jvm

Information about the classes and methods that are loaded is in the method Area. The constant pool is filled with objects of the basic type wrapper class such as Integer.Byte.Short. and the string that Appears.

Each time the new object is allocated to the object, it is assigned to a header address in the heap memory. Each time you use the method, the memory is opened in the stack memory to use. the pointer and use of the variable in the Method. when the method ends, the stack memory is closed at any Time.

The JVM uses a separate thread to perform garbage collection when it is uncertain, and the garbage collector typically begins to traverse and tag the objects that are traversed from several root objects, and those objects that are not eventually flagged are reclaimed by the garbage collector

Developers can also use System.GC (); the method "urges" the garbage collector to recycle, but it cannot guarantee immediate recycling.

Recursive method: two necessary methods 1) how to use the method to invoke Yourself. 2) how to Return.--when not to call yourself to avoid the Cycle.

Classpath: Class.class.getClassLoader ()//class Loader.  GetResource (String name); Url.getfile (); Direct Getresource/start Stringname.

8-2 Advanced Basics Summary multi-threading, Network programming, Java Basics Supplement

Related Article

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.