Errors in java (2) and errors in java

Source: Internet
Author: User

Errors in java (2) and errors in java

Java, exeis the java Virtual Machine javadoc.exeused to create java file jdb.exe is the java debugger javaprof, exe is the profiling tool

Resolution 1:

Sleep is a Thread method. executing this method will cause the current Thread to pause for a specified time and give the execution opportunity to other threads. However, the monitoring status remains unchanged and will be automatically restored. Calling sleep does not release the object lock. Wait is an Object method. Calling the wait method for this Object causes this thread to discard the Object lock and enter the waiting lock pool for this Object, only after the notify method or notifyAll method is issued for this object can this thread obtain the object lock and enter the running state. Resolution 2: notity () and policyall () methods are acceptable, it should enter the ready state rather than the running state. Exceptions include non-checkable RuntimeException and its sub-classes, that is, runtime exceptions. runtime exceptions are code bugs and checkable exceptions, that is, non-runtime exceptions, the program will find exceptions during compilation, such as IOException. When processing file streams like this, java enforces that it must handle possible file stream exceptions. RuntimeException is an exception during running. When an exception is thrown during running, the program can choose whether to try-catch the exception. For other checked exceptions (non-runtime exceptions, such as IOException), try-catch is required. Otherwise, the program will find errors during compilation.

We all know the memory allocation at jvm runtime. One of the memory areas is the jvm Virtual Machine stack. Each thread has a thread stack during running, and the thread stack stores the variable value information during running. When the thread accesses a value of an object, it first finds the value of the variable corresponding to the heap memory through the object reference, load the specific value of the heap memory variable to the local memory of the thread and create a copy of the variable. Then, the thread no longer has any relationship with the variable value of the object in the heap memory, instead, the value of the copy variable is directly modified. At a certain time point after modification (before the thread exits), the value of the copy of the thread variable is automatically written back to the object's heap variable. In this way, the value of the object in the heap changes.

Java provides a system-level thread, namely, the garbage collector thread. It is used to track every allocated memory space. When the JVM is idle, it automatically recycles each memory that may be recycled. GC is completely automatic and cannot be executed forcibly. The programmer can only use System. gc () at most to recommend that the Garbage Collector recycle memory. However, the specific time for garbage collection is unknown. When the referenced variable of an object is assigned null, it may be treated as garbage. The source code program uses an important internal interface: Map. Entry. Each Map. Entry is actually a key-value pair. When the system decides to store the key-value Pair in HashMap, the value in the Entry is not considered at all. It only calculates and determines the storage location of each Entry based on the key. The Entry is an array, and each element in the array is linked to this chain table .. The linked list method organizes objects with the same hash value into a linked list and places it in the slot corresponding to the hash value. The open address method uses a detection algorithm, when a slot is occupied, continue to find the next slot that can be used. Obviously, we are not using the open address method. J2Sdk is a programming tool developed by Sun. Java api is an application interface JAR (Java Archive, Java Archive). It is a platform-independent file format and allows many files to be combined into a compressed file. The JAR file created for the J2EE application is an EAR file (Enterprise JAR file ). Open java-jarAppletViewer is an html-related appletviewer that provides a Java runtime environment where you can test the Applet of a small application. Appletviewer reads HTML files containing small applications and runs them in a window.

 

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.