站内搜索: 请输入搜索关键词
当前页面: 图书首页 > Java Threads, Third Edition

6.6 Summary - Java Threads, Third Edition

Previous Section  < Day Day Up >  Next Section

6.6 Summary

The strong integration of locks into the Java language and API is very useful for programming with Java threads. Java also provides very strong tools to allow thread programming at a higher level. With these tools, Java provides a comprehensive library to use for your multithreaded programs.

Even with this library, threaded programming is not easy. The developer needs to understand the issues of deadlock and starvation, in order to design applications in a concurrent fashion. While it is not possible to have a program threaded automatically梬ith a combination of using the more advanced tools and development practices, it can be very easy to design and debug threaded programs.

6.6.1 Example Classes

Here are the class names and Ant targets for the examples in this chapter:

Description

Main Java class

Ant target

Deadlock-detecting Lock

javathreads.examples.ch06.example1.DeadlockDetectingLock

ch6-ex1

Alternate Deadlock-detecting Lock

javathreads.examples.ch06.example2.AlternateDeadlockDetectingLock

ch6-ex2


Three tests are available for each example. The first test uses two threads and two competing locks. The second test uses three threads and three competing locks. The third test uses condition variables to cause the deadlock. Test numbers are selected with this property:

<property name="DeadlockTestNumber" value="2"/>

    Previous Section  < Day Day Up >  Next Section