|Chapter 16: Concurrent Programming with Java Threads|
|Source Code in This Chapter|
Threadand defines a
runmethod that counts up to a specified value, pausing for a random time interval in between value counts.
Runnableinterface while providing a
runmethod for thread execution.
Counter2) that count from 0 to 4. In this case, the driver does not start the threads, as each thread is automatically started in
Counter2's constructor. Uses the following class:
Runnablethat counts to a specified value and sleeps a random number of seconds in between counts. Here, the thread is started automatically when the object is instantiated.
RSAKeycomputes an RSA public-private key pair, where the key size has a specified number of digits. As large prime numbers require considerable CPU time,
ThreadedRSAKeyconverts the original
RSAKeyto a multi-threaded method, thus allowing simultaneous (multithreaded) computation of multiple key pairs. Uses the following classes:
repaintto schedule an update of the display.
drawmethod to paint the circle on the graphics object.
paintmethod. The graphics object is obtained by calling
getGraphics. See Rubberband.html.
updateto reduce animation flickering and performing incremental updating in the
paintmethod. Here, to achieve animation, a single thread continuously calls
repaintwhile subsequently sleeping for a 100 milliseconds. See Bounce.html. Uses the following classes:
Threadholding the images for the animation.
Timer. Note that
Timeris located in the
javax.swingpackage. See TimedAnimation.html (requires Netscape 6.x or a browser that supports Swing). Uses the following classes and images:
TrainingAbout the Instructor
Intermediate Servlet & JSP Training Courses
Advanced Servlet & JSP Training Courses
SCWCD Training Courses
Jakarta Struts Training Courses
JavaServer Faces (JSF) & Apache MyFaces Training Courses
Ajax Training Courses
Java 5 & 6 Programming Training Courses
Customized On-Site Training Courses
Public Training Course Schedule
TutorialsApache Tomcat Tutorial
Intermediate Servlets & JSP Tutorial
Advanced Servlets & JSP Tutorial
SCWCD (Sun Certified Web Component Developer) Exam
Jakarta Struts Tutorial
JavaServer Faces (JSF) & Apache MyFaces Tutorial
Java 5 & 6 Programming Tutorials
Tutorials in Chinese
Tutorials in Japanese
ConsultingOur consulting services
JobsWe are hiring!