Preface: Recently in learning Java Multi-threading, see Importnew Online has a netizen translation of an article "block queue to achieve producer consumer model". In this article, the blocking queue in Java's concurrent package is used. After reading, implement the blocking queue by itself.(i) PreparationIn multi-threading, producer-consumer issues are a classic multithreaded synchronization issue. In short
client can restart the connection after a certain amount of delay.Although the socket has a keep alive option to maintain the connection, if this option is used, it typically takes two hours to discover the other party's outage, abnormal exit, and network connectivity .。 3, is the processing efficiency problem. Whether it's a client or a server,if it is a long connection a program requires at least two threads, one for receiving data, one for sending Heartbeat, writing data does not require a d
Java Basics:
The difference between ArrayList and LinkedList and the underlying implementation principle
ArrayList
Add Operation implementation
Expansion factor
HashMap and Councurrenthashmap
HashMap
Put operation
Expansion mechanism
Thread safety issues
I/O issues are one of the main problems in today's web applications, and in this era of data explosion, it can be said that application performance bottlenecks are I/O bottlenecks .Java I/O operations class under package java.io, there are approximately 80 classes, these classes can be divided into the following 4 groups:
Byte-based operation of I/O interfaces: InputStream and OutputStream;
I/O int
The difference between collection and collections in 1,javaJava.util.Collection is a collection interface. It provides a common interface method for basic manipulation of collection objects. The collection interface has many specific implementations in the Java class Library. The meaning of the collection interface is to provide a maximum unified operation for a variety of specific collections.Java.util.Collections is a wrapper class. It contains a va
Tomcat + java web programs continue to occupy cpu issues for debugging
Symptom:
Deploy Java web applications in tomcat. After a while, the java Process of tomcat continues to occupy up to 100% of the cpu, leading to blocked web application access.
Possible Cause Analysis:
The program may indeed perform data computing;
to int type2, the large capacity of the data type converted to a small capacity data type, to add a forced conversion, but may result in reduced precision or overflow;3, there are many types of data blending operations, the system first automatically converts all data to the largest capacity of the data type, and then the calculation.4, Real constants (such as: 1.2) default to Double.5, integer constants (such as: 123) default to int.# # # #值得注意的是:the equivalence between values is essentially c
with Heap Space.
Solution: Adjust the-xmx, if large enough to debug-refer to the following debug HEAP
The vicious circle of garbage collection- Note: This is almost the most common phenomenon
Phenomenon:JVM does not correspond, memory basic consumption, analysis GC log, will see spent a long time to do FULLGC, released a bit of memory, and quickly need to FULLGC, such as 10 seconds to do fullgc,1 seconds and then need to FULLGC and then 10 seconds to complete FULLGC, repeated
post to publish. All examples are personally tested and shared on GitHub. Use these examples to motivate yourself to benefit others. At the same time, all the posts in this series will be published in the blogger personal public search "Love Ape" or "ape_it" to facilitate reading. If there is any infringement of the original rights of the author, please inform the blogger in time to delete if the reader has objections to the content of the text or questions are welcome through the blog post or
pool threads can be set to CPU core number +1, reduce the switch of thread context(2) Concurrency is not high, task execution time long business to distinguish between the look:A) If the business time is concentrated on IO operations, that is, io-intensive tasks, because IO operations do not occupy the CPU, so do not let all the CPU idle, you can increase the number of threads in the thread pool, so that the CPU processing more businessb) If the business time is focused on computational operati
Java issues Summary of 15-calls between multiple classes:Code:Package Java3;public class Test1 {public static void main (string[] args) {pretimive t = new pretimive (); for (int i=0;iResults:falsefalsefalsetruefalsetrue00000000000123456789Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.Java issues Summary
Java Design Polling thread performance issues with while loopThe polling thread is widely used in the development process, where I simulate a scenario that has a queue and polling thread, the main thread queues messages into the queue, and the polling thread loops through the queue to read the message and print the message content. A bit like handler in Android sends messages. First define a message class.p
This baby novice, do not spray! Directly on the code,Thread-wide sharing issues: sharing the same block of data between each thread, one data corruption is all damaged, you need to run a bit!public class Threads {private static Hashmappublic static void Main (string[] args) {for (int i = 0; i New Thread (New Runnable () {@Overridepublic void Run () {int value = new Random (). Nextint (1000);Data.put (Thread.CurrentThread (), value);System.out.println
By:java.lang.ClassNotFoundException:com.tgb.itoo.authority.entity.Discution from[module "Org.apache.shiro: Main "from local module loader @768b970c (finder:local module finder @5a4041cc (roots:e:\java\jboss-eap-6.2\modules,e:\ Java\jboss-eap-6.2\modules\system\layers\base)]This exception, is added Shiro problem, generally caused friebug collapse, restart the friebug can be.12:11:38,827info [stdout] (server
connection, network connection and IO connection.In the process of operating the database, you need to establish a connection to the database (Connection,statement,resultset), when no longer in use, you need to call the Close method to release the connection, only after the connection is closed, the garbage collector will reclaim the corresponding object.3) Listener4) The scope of the variable is unreasonableIf the scope of a variable definition is greater than its scope of use, it is likely to
1 What does each word mean in the following code? Public y① class ② Hello ③ { Public④Static⑤void⑥Main⑦(string[] args)⑧{}}① and ④ indicate public access to other classes② is a declaration of a class③ is the name of the class⑤ represents static⑥ represents no return valueThe name of the ⑦ method a program has and only one main method is the Main method⑧ must pass an array of string to this method when the parameter is named args.How does the 2Java work?source code → compiler → output → r
; import Java.io.InputStream; public class Test { public static void main (string[] args) throws Interruptedexception, IOException {InputStream is = system.in; int i = Is.read (); System.out.println ( "exit. "); }}Also we first find Javaw.exe pid, and then use jstack analysis of the PID, soon Jstack help us find the location, Test.java file 12 lines , as follows:OtherLike calling sleep to put a thread into sleep,suspend () pauses the thread and so on is not an example, i
detection finds that the top of the stack is still a, so the CAs succeeds, the stack top changes to B, but in fact the b.next is null, so this situation becomes:Where there is only a B element in the stack, a list of C and D no longer exists on the stack, and C and D are discarded for no apparent matter.The above is due to the problem of ABA problems, the implementation of various optimistic locks are usually used in version to mark the record or object, to avoid the problems caused by concurre
Threads3*use of thread concurrency Sync lock synchronized (Object) {}4*/5 Public classTHREAD05 {6 Public Static voidMain (string[] args) {7 //define a ticket window8Ticketwindow tw1=NewTicketwindow ();9 Ten //start at the same time with three threads OneThread t1=NewThread (TW1); AThread t2=NewThread (TW1); -Thread t3=NewThread (TW1); - the T1.start (); - T2.start (); - T3.start (); - } + } - + //Ticket window class A classTicketwindowImplementsRunnab
available, then use this method to get ServletContext directly:Contextloader.getcurrentwebapplicationcontext (). Getservletcontext ()update20151228:When you write a file, you may need to obtain a path, such as when uploading a file that requires an output stream. the output stream cannot be obtained directly through ServletContext, but the actual path can be obtained directly. such as:Servletcontext.getrealpath ("/")The path obtained is the ${context}/path, and the output stream is obtained bas
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.