开发者

java concurrency assignments [closed]

开发者 https://www.devze.com 2022-12-29 20:34 出处:网络
It's difficult to tell what is being asked here. Thi开发者_如何学Pythons question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current f
It's difficult to tell what is being asked here. Thi开发者_如何学Pythons question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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:

  1. How would you implement a simple blocking queue?
  2. How do you stop a thread?
  3. How would you ensure only a single thread can read and write to a collection at a time?
  4. What would happen if you modify a collection while another thread is iterating over it.
  5. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消