Discover java concurrency in practice book, include the articles, news, trends, analysis and practical advice about java concurrency in practice book on alibabacloud.com
(string[] args) throws Executionexception, Interruptedexception {Forkjoinpool pool = new Forkjoinpool ();Cumulative Sum 0-20000000LCounttask task = new Counttask (0, 20000000L);Forkjointask result = Pool.submit (Task);SYSTEM.OUT.PRINTLN ("sum result:" + result.get ());}}The Forkjoin thread pool uses a lock-free stack to manage idle threads, which may be suspended if a worker thread temporarily does not get the available tasks.The suspended thread is pressed into the stack maintained by the thre
I recently read Java Concurrent in Practice (java Concurrent programming Practice) and found that I have a superficial understanding of java threads, locks, and other mechanisms, and I have not learned fully enough. I plan to use this bo
of Java programming.
Obtain products and technologies
Jtune: a free jtune tool that allows you to use GC logs and graphically display the heap size, GC duration, and other useful memory management data.
Discussion
Join this forum. (You can also click the forum link at the top or bottom of the article to participate in the discussion .)
Developerworks blogs: Join the developerworks community.
Collections.synchronizedMap class Collections.synchronizedList , and Map List provides the basic conditional thread-safe implementation. However, some factors make them not suitable for highly concurrent applications-their collection-scoped single-lock feature is a barrier to scalability, and many times a collection must be locked for a longer period of time to prevent ConcurrentModificationException s-exceptions. ConcurrentHashMapand CopyOnWriteArrayList implementations provide higher
Telescopic
Content:
Synchronized Quick Review
The improvement of the synchronized
Compare the scalability of Reentrantlock and synchronized
Condition variable
It's not fair
Conclusion
Resources
About the author
The evaluation of the paper
Related content:
Java Theory and Practice series
Synchronization is not the enemy
Reducing contention
IBM developer Kits for the
The new lock class improves synchronicity--but it can't be abandoned right now. SynchronizedJDK 5.0 provides a number of new and effective options for developers to develop high-performance concurrent applications. For example, a java.util.concurrent.lock class in the ReentrantLock Java language is synchronized replaced with the same memory semantics, the same lock, but with better performance under race conditions, and there are synchronized other fe
overhead of mutex. However, in addition to the overhead of mutex, CAS operations are also performed, therefore, in the case of competition, lightweight locks will be slower than traditional heavyweight locks.1.5 references1. Java 7 concurrency Programming Practice Manual2. java synchronized3. Talk about
Java Theory and Practice:Concurrent collection classConcurrenthashmap and copyonwritearraylist provide thread security and improved scalability.
Document options
Valign = "TOP"> Width = "122">
. Following these patterns (not exceeding their limits when using them) can help you implement most use cases safely and use volatile variables for better performance.Reference Learning
You can refer to the original English text on the DeveloperWorks global site in this article.
Java Concurrency in practice: How-to Manual for developing concurrent p
Java Theory and Practice: non-blocking algorithm introduction-Linux general technology-Linux programming and kernel information. The following is a detailed description. Java™5.0 for the first time, it was possible to develop non-blocking algorithms using the Java language. The jav
outstanding open source Concurrency Toolkit, java.util.concurrent, which contains mutex, trust, and performance-performing collection classes such as queues and hash tables, and some work queue implementations under concurrent access. The Pooledexecutor class in this package is an efficient, widely used, and correct implementation of a thread pool based on a work queue. Instead of trying to write the code yourself, it's easy to make mistakes, and you
cases provides better performance and scalability than locks. If you strictly follow the use of volatile conditions-that is, the variable is really independent of the other variables and its own previous values-in some cases you can use the volatile substitution synchronized to simplify the code. However, volatile the code used is often more error-prone than code that uses locks. The pattern described in this article covers some of the most common use cases that can be used volatile instead syn
alternative locking methods, including comparison and exchange, to build concurrent algorithms.
See summarizes research in wait-free algorithms at the warping group (real-time processing without waiting technology) site.
"A more flexible and scalable locking mechanism in JDK 5.0" (developerworks, October 2004)ReentrantLockThis section describes the random number generation benchmark used in this column.
Doug Lea'sConcurrent Programming in Java, Se
Java: Practice Supermarket storesRelated to: large commodity, specific goods (in the case of books), store categoryGoods,book,Supermart,Product Class Goods:Public interface Goods {//Commodity class public String getName ();p ublic int getcount ();p ublic float GetPrice ();}Book:Note: The replication hashcode, and equals is to implement the Delete buttonPackage Ab
Singleton mode is one of the most common and important design patterns in Java design patterns.The simplest notation is: Public classTestsingleton {Private StaticString ourinstance =NULL; //Privatization Constructor PrivateTestsingleton () {}//provides static methods for external access Public StaticString getourinstance () {if(Ourinstance = =NULL) {ourinstance= "Singleton mode assignment succeeded!!!" "; System.out.print (ourinstance);
, including creating and writing thread-safe classes and programs, avoiding performance impact, managing performance, and testing concurrent applications.
Popular Atoms: Introduced the new atomic variable class in Java 5.0. This feature extends the volatile variable to support atomic state conversion.
Introduction to non-Blocking Algorithms: Describes how to use atomic variables instead of locks to implement concurrent algorithms.
Volatiles: Get mo
I always wanted to learn Java because of curiosity and free. But because it is not used at work, and it is too high in hardware configuration, it is only occasionally used to learn. I have found tutorials and articles on the Internet, but I have not learned anything. I also bought more than 700 pages of Java j2se 5 edition reference book, because it is too thick
The Java language provides flexible, seemingly simple threading capabilities that make it easy to use multithreading in your applications. However, concurrent programming in Java applications is more complex than it seems: in Java programs, there are subtle (and perhaps not subtle) ways to create data contention (race) and co
Java and design patterns in Spring practice-collection
Spring practice
Labels: Java and Design Patterns
Junit Integration
Previously used multiple times@RunWithAnd@ContextConfigurationAdd these two annotations to the test class, and the program will automatically load the Spring configuration and initialize the Spr
Android practice-DEMO (JAVA keyword learning) 1
The best way to learn technology is practice. There are too many things you can't see when reading a book. In practice, you may encounter problems that cannot be found in various books. Solving these problems will quickly impro
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:
[email protected]
and provide relevant evidence. A staff member will contact you within 5 working days.