question one: What's wrong with using HashMap in a multithreaded environment? Under what circumstances does the get () method produce an infinite loop? There is no problem with HashMap itself, and there is no problem depending on how you use it. For
Packageunit8;ImportJava.applet.Applet;ImportJava.awt.Label;ImportJava.awt.TextField; Public classTestrunnableextendsAppletImplementsrunnable{Label prompt1=NewLabel ("The first thread:"); Label Prompt2=NewLabel ("The second thread:"); TextField
when the program is running, we cannot guarantee that all the services and methods are correct, and if an error occurs, it will cause the program to crash, so you need to handle some predictable errors, throw an exception by throwing, and then use
Question 1:Why Wait () and notify () are methods in the object class, not methods in the thread class?A: Because the lock is an arbitrary object, in the object class, if the lock object is not arbitrary in the thread class.
Question 2:Why Wait ()
1.java has classes of overrides and overloads of 2 kinds: overloading is the same class, the method name is the same, the parameter differs from the method, and the overriding is that the subclass inherits the parent class method, and the rewrite
Java Knowledge points:Object-oriented:Object-oriented is a kind of thoughtProgramming guidancePackaging:Object-oriented 2 large core:1. Class: Descriptive information, abstractFormat: [public/abstract/final] class name {PropertyConstruction
File name: "Simpleservlet.java"Package cn.mldn.lxh.servlet;//Defining packagesImport java.io.*;HttpServlet belongs to the Javax.servlet.http packageServletexception belongs to the Javax.servlet packageImport javax.servlet.*;//Importing
Scenario: Thread A needs the execution result of thread B, but there is no need to wait for thread B to finish, this time we can get the future object, and wait for the end of thread B to take the real result. Defines realdata real data classes
When there are too many properties in a bean, it is a very troublesome thing to calculate the sum of a bean's list, which can be solved with the reflection mechanism of Java, the code is as follows:
Requirement: Simulate three windows and buy tickets at the same time.Problem 1:static modifies num to create only one copy in memory, or 3 copies are created.Issue 2: Thread safety issues. (The code weighs 1 in the red font)Cause: There are two or
Problem Description:Today suddenly want to write a small application of socket communications, respectively, using bio, NIO, AIO way to achieve, to review the previous reading about TCP/UDP communication knowledge. The jdk1.8 was re-installed on the
Cloneable interface is an empty interface, only for tagging objects, the Cloneable interface is not the Clone () method, the Clone () method is the method inside the object class! The default implementation is a native methodProtected native Object
Tokens in Java generics mean:E -Element (used in the collection because the element is stored in the collection)T -type (Java Class)K -Key (key)V -value (values)N -Number (numeric type)? -Represents an indeterminate Java typeS, U, V -2nd, 3rd, 4th
KeySet ():deposits all the keys in the map into the set collection. Because set has an iterator, you can take all the keys iteratively, and then get the value for each key based on the Get method, which only takes the key through get (). EntrySet ():
Public Static voidMain (string[] args) {File File=NewFile ("E:\\\\eclipse\\\\workspace\\\\helloworlddocker\\\\log"); //determine if the file directory exists, and is a file directory, non-file if(File.exists () &&file.isdirectory ()) {file[]
I. Explanation of the packageWhat is encapsulation? Why encapsulation? How to implement encapsulation?The purpose of encapsulation is to improve the security of the program. Encapsulation is a way to hide the attributes that you don't want the third
1 Loading the configuration fileWrite the configuration file config.properties in the SRC directory of the Common Java project (if MAVEN works in the project's Src/main/resources)
1, Spring has shaken the Sun's Java EE Traditional heavyweight framework (EJB) with its own power, becoming the most used Java EE Enterprise application development Framework.2, Spring is a layered Java EE application of a one-stop lightweight
first, read characters with DataInputStreamYou can use the available method to see how many characters are available for access. examples are as follows: public class Test1 { publicstaticvoidthrows IOException { DataInputStreamin =new
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