JAVA OLYMPUS.com


aa Contact Us aa Home aa About Us aa Sign Up aa Free Java Books aa Java Books




JAVA THREADS

   
JAVA 2
Subcategories

JAVA LANGUAGE
   Getting Started
   Java Fundamentals

J2SE
   Annotations
   Applets
   Auto Boxing
   AWT
   Beans
   Collections
   Ennumerated Types
   Exceptions
   Garbage Collection
   Generics
   Immutable Types
   Internationalization
   JNI
   JVM
   I/O
   Logging
   Preference
   Reflection
   Serialization
   RunTime (JRE)
   Threads
  Database Access
   JDBC
   SQLJ
   JDO
  JFC
   J2D
   Drag & Drop
   Swing
  Media
   J2D
   J3D
   JAI
   JMF
   JTAPI
   IMAGE I/O
   SDT
   Sound (JSAPI)
   Speech
  Networking
   CORBA
   JNDI
   IDL
   RMI/IIOP
   Sockets
  Security
   JAAS
   JCE
   JSSE

JINI
   Spaces

OTHER
   Java Agents
   Java Performance
   Java Design
   AOP
   Java Certification


JAVA NETWORK
   JavaOlympus
   J2EEOlympus
   JSPOlympus
   J2meOlympus





Secure thread collaboration across protection domains When threads collaborate across protection domains, they introduce interesting wrinkles into the science of building secure applications. This month, Todd Sundsted presents these scenarios and shows how to use the AccessControlContext and GuardedObject classes to build solid solutions
Lock on to an alternate synchronization mechanism Tarak Modi shows how to create a reader/writer lock for multithreaded programming. That synchronization mechanism is useful if you don't want to prevent other threads from simultaneously reading a shared resource yet still want to allow only one thread to modify the resource. The implementation discussed here includes lock upgrade and downgrade capabilities. Enhancements such as lock-leasing, various performance improvement tips, and ways of dealing with issues such as priority inversion are also discussed
Scale an application from 2 to 3 tiers with JDBC The Forum application that we created earlier this year is a pretty nifty bulletin-board system, but it needs some work if we want to make it a production-grade application. This month, we'll develop a JDBC communications layer that talks to a simple Microsoft SQL Server 6.5 database, and then build the layer into the server for the discussion forum. The resulting application will act as a JDBC-based middleware layer for the Forum application. You can apply this same technique to any networked Java application that needs to scale or that could benefit from talking to a database.
Secure thread collaboration across protection domains When threads collaborate across protection domains, they introduce interesting wrinkles into the science of building secure applications. This month, Todd Sundsted presents these scenarios and shows how to use the AccessControlContext and GuardedObject classes to build solid solutions.
Lock smith : Can you lock class-level static variables? Can I lock class-level (static) variables? A static member attribute can be modified by more than one calling program at a time;
Threads Tutorial A thread--sometimes called an execution context or a lightweight process--is a single sequential flow of control within a program. You use threads to isolate tasks. When you run one of these sorting applets, it creates a thread that performs the sort operation. Each thread is a sequential flow of control within the same program (the browser). Each sort operation runs independently from the others, but at the same time.
Creating a Threaded Slide Show Applet A thread is a path of execution through a program. Single threaded programs have one path of execution, and multi-threaded programs have two or more paths of execution. Single threaded programs can perform only one task at a time, and have to finish each task in sequence before they can start another. For most programs, one thread of execution is all you need, but sometimes it makes sense to use multiple threads in a program to accomplish multiple simultaneous tasks.
Threading and Concurrency in the Java Platform January 9, 2001 Welcome to Java Live! Today's topic is on threading and concurrency. Our guests are two consultants and educators who specialize in the area of high-performance computing: Thomas Christopher and George Thiruvathukal. They're co-authors of the new Java series book High-Performance JavaTM Platform Computing, recently published by Sun Microsystems Press. They'll answer your questions about threading and concurrency.
Using a Swing Worker Thread This article gives examples of using the SwingWorker class. The purpose of SwingWorker is to implement a background thread that you can use to perform time-consuming operations without affecting the performance of your program's GUI.
SwingWorker Update Fixes Subtle Bug This article is aimed at people who've used earlier versions of SwingWorker. It tells you how to convert to SwingWorker 3 and then discusses the bug that SwingWorker 3 fixes. For more information on SwingWorker, see the following two articles, which have been updated to use SwingWorker 3:
Using Synchronized Statements This article is aimed at people who've used earlier versions of SwingWorker. It tells you how to convert to SwingWorker 3 and then discusses the bug that SwingWorker 3 fixes. For more information on SwingWorker, see the following two articles, which have been updated to use SwingWorker 3:
What is Concurrent Programming? Until now, we have been exclusively concerned with sequential programs that execute a single stream of operations. Even the GUI programming in the previous section avoided concurrent execution by terminating the controller as soon as it finished setting up the model and view. Concurrent computation makes programming much more complex. In this section, we will explore the extra problems posed by concurrency and outline some strategies for managing them.
Race Conditions and Mutual Exclusion Chapter 3 of "High Performance Java Computing : Multi-Threaded and Networked Programming"
Monitors Chapter 4 of "High Performance Java Computing : Multi-Threaded and Networked Programming"
WHY USE THREADS? Support for concurrent programming is a central feature of the Java TM programming language. The java.lang package includes the Thread class, which allows you to start multiple threads of execution in your program. On a multi-cpu machine, threads increase performance by allowing your code to use all of the available processors.
A Simple, Multithreaded Web Server The following code implements a simple, multithreaded HTTP server in a few hundred lines of Java code. Here's how it works: The main thread initializes the server and starts a number of worker threads that will handle client connections. The worker threads simply wait around idle until there's a client to service. The main thread then accepts connections from clients, passes off the connection for a worker thread to handle, and continues accepting new connections.
A Portable Multithreaded Web Server Portability and performance are two of the most desirable attributes for a web server, yet most servers lack one or the other. Some of the more portable offerings tend to be simplistic, while the high-performance servers are generally system specific.
Concurrent Programming Using Java To give software professionals and operating systems and concurrent programming students experience writing concurrent programs in Java, a well-known programming language. This will reinforce and increase their knowledge of semaphores, monitors, message passing, remote procedure calls, and the rendezvous as tools for concurrent thread synchronization and communication. Detailed Description of the Book
Multi-threading in Java programs See how easy it is to develop and use threads Using multiple threads in Java programs is far easier than in C or C++ because of the language-level support offered by the Java programming language. This article uses simple programming examples to demonstrate how intuitive threading in Java programs is. Users should be able to write simple, multi-threaded programs after studying this article.
Designing for Thread Safety This installment of the Design Techniques column gives you design guidelines that pertain to thread safety. It provides a background on the concept of thread safety and shows several examples of objects that are and are not thread-safe, including two illustrative applets. In addition, the article offers guidelines to help you decide when thread safety is appropriate and how best to achieve it
Multi-threading in Java All At Once As users we are familiar with multithreaded applications. For example, word processors print in the background and Web browsers fetch several images at once for better performances.
Unraveling threads Multi-threaded programming offers developers substantial advantages, and users increased performance. Despite the obvious benefits, novice programmers are reluctant to write multi-threaded applications because of their perceived complexity.
Threads and Swing This article about multithreading in Swing was archived in April 1998. A month later, we published another article, "Using a Swing Worker Thread", expanding on the subject. For a better understanding of how multithreading works in Swing, we recommend that you read both articles.
The Last Word in Swing Threads Working with Asynchronous Models This is not an article in any particular series, but it is the third article that The Swing Connection has published on the use of threads in Swing.
Extending Java to Support Shared Resource Protection and Deadlock Detection in Threads Programming Java threads enable programmers to write parallel programs very easily and conveniently. However, the current Java specification does not adequately provide for the protection of shared resources or for deadlock detection, two of the most common problems arising from parallel programs. The ability to solve these problems is crucial for Java concurrent programming. In this paper, we introduce and implement a model that can aid in writing parallel programs by providing shared resource protection and deadlock detection.
Threads, Synchronization, and Animation MUST AN APPLET BE COMPLETELY DEPENDENT on events sent from outside to get anything done? Can't an applet do something on its own initiative and on its own schedule? Something more like a traditional program that just executes a sequence of instructions from beginning to end?
Multithreading Tutorial This chapter introduces you to multithreaded programs and how multithreading is supported in Java. You'll learn how to create, run, and synchronize multiple threads in your programs. You'll also learn about thread scheduling and how a thread's priority determines when it is scheduled. When you finish this chapter you will be able to develop multithreaded programs using Java.
Multithreaded Programming in Java When Two Threads are Better Than One Many real-world software problems can best be solved by using multiple threads of control. For example, an interactive program that displays data graphically often needs to let users change display parameters in real time. Interactive programs often obtain their best dynamic behavior using threads.
CREATING AND CONTROLLING THREADS A thread is a sequence of executing instructions that can run independently of other threads yet can directly share data with other threads.
If I were king: A proposal for fixing the Java programming language's threading problems Allen Holub suggests that the Java programming language's threading model is possibly the weakest part of the language. It's entirely inadequate for programs of realistic complexity and isn't in the least bit object oriented. This article proposes significant changes and additions to the Java language that would address many of these problems.
Thread Safe Streams Multi-threaded programming offers developers substantial advantages, and users increased performance. Despite the obvious benefits, novice programmers are reluctant to write multi-threaded applications because of their perceived complexity. This article will offer a gentle introduction to multi-threaded programming
Generic Design Pattern Language for Distributed Computing Multi-threaded programming offers developers substantial advantages, and users increased performance. Despite the obvious benefits, novice programmers are reluctant to write multi-threaded applications because of their perceived complexity. This article will offer a gentle introduction to multi-threaded programming
Java's Swing API is not thread safe in general, but it can be made more so with just a few small additions. Swing is Java's pluggable look-and-feel user interface toolkit. Unlike many other Java packages and classes, Swing is not multithreaded. Once the user interface is created and painted to the screen, all updates to it must occur in the Swing event dispatch thread. The event dispatch thread is automatically started when the application or applet starts up, and all repaint and listener (user event handling) code is executed in this thread.
Java: Threads, Networks, RMI, and Native Interfaces Though Java incorporates multithreading into the langauge, considerable work is required to use threads properly in a nontrivial program. This class starts out with an in-depth look at multithreading in the Java environment and at how to program effectively with threads.
Programming Java threads in the real world, Part 1 A Java programmer's guide to threading architectures Programming Java threads isn't nearly as easy (or as platform-independent) as most books would have you believe, and all Java programs that use the AWT are multithreaded. This article is the first in a series that discusses the things you need to know to program threads in the real world. The article assumes you understand the language-level support for threads (the synchronized keyword, how monitors work, the wait() and notify() methods, and so on) and focuses on the legion of problems that arise when you try to use these language features.
Java Toolbox: Programming Java threads in the real world, Part 2 This article, the second in a multipart series on threads, discusses the perils that can arise when you approach multithreading in a naive way. As is the case with the entire series, this article assumes reader familiarity with the basic thread-related parts of Java: the synchronized keyword and monitors, wait(), notify(), the basics of using the Thread class, and so forth. Here, Allen focuses on the more advanced problems encountered when programming Java threads in the real world.
Programming Java threads in the real world, Part 3 Roll-your-own mutexes and centralized lock management In Parts 1 and 2 of this series on threads, Allen looked at some of the pitfalls of writing multithreaded applications in Java. This month, he starts looking at a few solutions. In particular, he looks at how and why you might want to roll your own exclusion semaphores, and presents a lock manager that will help you safely acquire multiple semaphores.
Programming Java threads in the real world, Part 4 Condition variables and counting semaphores -- filling in a few chinks in Java's threading model This column continues where last month's column left off, presenting a few more implementations of classes that are useful when you're doing multithreading in Java. The two classes I'll discuss provide capabilities difficult to get using Java's threading primitives alone: a condition variable adds to wait the ability to not wait when the condition you're waiting for has already taken place; and a counting semaphore lets you control a pool of resources without sucking up machine cycles in polling loops. This month's column also discusses a few minor fixes to the code presented last month.
Programming Java threads in the real world, Part 5 In an aside to his running series on programming Java threads in the real world, Allen prefaces this month's column with a look at one dangerous new "feature" of the Java 2 platform: the ability to produce noncompliant class files that will not run on a 1.1 Java virtual machine (JVM).
Programming Java threads in the real world, Part 6 This month continues the thread theme by examining how to implement the Observer pattern (used by AWT/Swing for its event model) in a multithreaded environment. The article covers how to notify observers in an efficient, thread-safe way using code modeled after Java's AWTEventMulticaster. It also considers a few problems with AWT/Swing's use of Observer.
Programming Java threads in the real world, Part 7 This month's column builds on the preceding installments of the Java Toolbox threads series, adding a few more tools to your multithreading arsenal. Columnist Allen Holub looks at reader/writer locks, which let multiple threads safely access a shared resource in an efficient way. (Multiple threads can read from the resource while only one thread at a time can write to it, and reads and writes can't occur at the same time.) He'll also discuss the Singleton pattern, with a focus on implementing it in a multithreaded environment, and critical sections, or blocks of code that can be executed by only one thread at a time.
Programming Java threads in the real world, Part 8 The previous installment of Allen's ongoing Java threads series was devoted to low-level solutions to threading problems: locks of various sorts, timers, and so forth. This month's (penultimate) installment in the thread series moves on to discuss architectural solutions to threading problems. Allen looks at threads from the perspective of an object-oriented designer, and at how to implement threads in an object-oriented environment, focusing on the implementation of asynchronous methods. Along the way, he discusses the Command design pattern.
Programming Java threads in the real world, Part 9 This article finishes up the series on threads with a discussion of two more architectural solutions to threading problems: a synchronous dispatcher (or "reactor") and an asynchronous dispatcher (or "active object"). These dispatchers can simplify the threading model considerably by letting you minimize -- and in some cases eliminate -- the need for method-level synchronization, thereby making it much easier to write and debug multithreaded applications
Improve the robustness and performance of your ObjectPool In our previous object-pooling article Thomas E. Davis presented an example object pool design and described how to employ this approach to boost performance and minimize memory use. This month, after providing a quick recap of object pooling, Thomas will show you how to enhance the example pooling utility to include exception propagation and the clean-up thread. Thomas finishes by addressing some reader comments about the first article.
Build your own ObjectPool in Java to boost app speed Object pooling allows the sharing of instantiated objects. Since different processes don't need to reinstantiate certain objects, there is no load time. And since the objects are returned to the pool, there is a reduction in garbage collection. Read on to learn, via the author's own example object pool design, how to employ this approach to boost performance and minimize memory use.
Write your own threaded discussion forum Forum, discussion group, bulletin board, a rose by any other name. Discussion forum software makes a handy addition to any site that wishes to provide asynchronous discussion capability for its users. This installment of Java Step by Step walks through the process of a designing and writing Interchange, a simple multi-topic discussion system with a few basic security features. The discussion is in two parts. In this month's edition we'll spec out the system and build the client. Next month we'll finish up the client-side networking, build the server, and deploy the system.
Synchronizing threads in Java, Part 1 Java's built-in multithreading capability makes it easy to build powerful multiprocessing applets. Synchronizing the activity of these separate executing entities is crucial to reliable and predictable applet behavior. Walk through a simple example illustrating the use of the wait() and notify() functions.
Using threads in Java, Part 2 Communicating between threads is made easy by developing a class that uses the techniques discussed in the first part of this series. Herein, see firsthand how to write such a data channel class, and then create a simple example application that illustrates a real-world implementation of the class.
Avoid synchronization deadlocks Though essential for ensuring the thread safety of Java classes, synchronization, if used improperly, can create the possibility for deadlocks. If you understand how your programs use synchronization, and apply consistent rules for acquiring multiple locks simultaneously, you can reduce the likelihood of synchronization deadlock in Java programs.
A Design Framework for Highly Concurrent Systems (2000) Building highly concurrent systems, such as large-scale Internet services, requires managing many information flows at once and maintaining peak throughput when demand exceeds resource availability. In addition, any platform supporting Internet services must provide high availability and be able to cope with burstiness of load. Many approaches to building concurrent systems have been proposed, which generally fall into the two categories of threaded and eventdriven programming. We propose that threads and events are actually on the ends of a design spectrum, and that the best implementation strategy for these applications is somewhere in between
The Staged Event-Driven Architecture for Highly-Concurrent Server Applications We propose a new design for highly-concurrent server applications such as Internet services. This design, the staged event-driven architecture (SEDA), is intended to support massive concurrency demands for a wide range of applications. In SEDA, applications are constructed as a set of event-driven stages separated by queues. This design allows services to be well-conditioned to load, preventing resources from being overcommitted when demand exceeds service capacity. Decomposing services into a set of stages enables modularity and code reuse, as well as the development of debugging tools for complex event-driven applications.
Writing efficient thread-safe classes Thread-safe and efficient -- now you can have both Though Java incorporates multithreading into the langauge, considerable work is required to use threads properly in a nontrivial program. This class starts out with an in-depth look at multithreading in the Java environment and at how to program effectively with threads.
Java technology, threads, and scheduling in Linux Patching the kernel scheduler for better Java performance This paper examines the performance of the Linux kernel when the system is running a Java program using the IBM Developer Kit for Linux, Java Technology Edition, Version 1.1.8. The Java program is the VolanoMark benchmark, a communication-intensive benchmark that creates a large number of Java threads. This implementation of the Java technology uses a native-threading model; each Java thread is supported by an underlying Linux process.
Java threads may not use all your CPUs Tests to confirm symmetric multiprocessing (SMP) scalability of processes and Java threads on Sun hardware have revealed a serious problem in Sun's JDK 1.1.7 that can dramatically reduce the performance of your server-side Java applications

    Java Threads
HOME PAGE:
J2SE

FAQ:
J2SE FAQ
Index FAQ

WHITE PAPERS:
The Java Language

SPECS:
java language
jvm

DOCS:
J2SE API Overview
Collections Documents
J2SE API
1.4 Enhancements
1.3 Enhancements
1.2 Enhancements
1.1 Enhancements
1.3 Data Sheets
Packages Hierarchy

DOWNLOADS:
J2SE 1.1
J2SE 1.2
J2SE 1.3
J2SE 1.4
J2SE 1.4.1
J2SE 1.4.2

ARTICLES:
Sun Articles

NEWSGROUPS:
J2SE Archives

TUTORIALS:
Reflection Tutorial
Java Basics 1
Java Basics 2
Java Basics 3
Advance Java
J2SE Tutorial
online training
audiocasts
Java Lectures

FORUMS:
J2SE forums

USER GROUPS:
Java User Groups

BOOKS:
Free Java Threads Books
Java Threads Books

BEST SITES:
java.about.com
J2EE Blueprints

theServerside.com
techmetrix
bea developer
JavaWorld
JavaDevelopersJournal
JavaReport
IBM jCentral
JavaPro
jMiddleware
javalobby
javacoffebreak
IBM Java
SIG-EJB
EJBPROVIDER

BeansforBusiness
EJBINFO