java concurrency assignments [closed]
I am Java EE developer, and I want to get skills on concurrency development.
Could you provide me some assignments, ideas, or other - just for learning and training concurrency programming?There's a brilliant book about Java concurrency called "Java Concurrency in Practice". I think this is the best starting point for diving deep into advanced concurrency.
Java Concurrency in Practice (Amazon)
To start with just start coding to get an idea of some of the problems that may arise.
To get you started try writing the following:
- How would you implement a simple blocking queue?
- How do you stop a thread?
- How would you ensure only a single thread can read and write to a collection at a time?
- What would happen if you modify a collection while another thread is iterating over it.
- etc, etc
Just go online and maybe do a search for interview questions on concurrency.
I have blogged about new concurrency solutions with the Spring framework 3 and Java EE 6 here.
It explains how to execute asynchronous methods declaratively with the @Async
or the Java EE's @Asynchronous
annotation.
These annotations are just a way to abstract away the complex concurrency logic.
You can configure Spring to use the excellent Executor
class to do the concurrency logic. The Exceutor class was introduced in Java 5 and is explained well in the Java Concurrency in Practice book together with the other classes in the java.util.concurrent
package.
The article also demonstrates how to use the same Executor
service in the code and by the Spring framework. Which enables you to use the same thread pool for both your programmatic concurrency logic and your concurrency logic handled by an application container.
Else, you can learn a lot from the Java documentation. Read about all the classes in the concurrent package and especially the Executor class. This is at least my most used documetation.
I would suggest looking at JCSP. http://www.cs.kent.ac.uk/projects/ofa/jcsp/
With JCSP it is possible to prove your models are deadlock free.
IBM have more information about it http://www.ibm.com/developerworks/java/library/j-csp1.html
精彩评论