Online Library TheLib.net » High-Performance Java Platform Computing: Multithreaded and Networked Programming
cover of the book High-Performance Java Platform Computing: Multithreaded and Networked Programming

Ebook: High-Performance Java Platform Computing: Multithreaded and Networked Programming

00
27.01.2024
0
0
Threading and concurrency are crucial to building high-performance Java applications -- but they have a reputation for complexity. High Performance Java Computing thoroughly demystifies these advanced development techniques. It delivers practical programming solutions, proven design patterns, and a rigorously-tested code library -- everything developers need to build optimized Java software for technical, business, and E-commerce applications. Start by understanding how threading and concurrency can be used to solve a wide variety of performance problems, enabling the construction of more powerful networked applications. Master the Java 2 Threads classes, including daemon threads, thread control, scheduling, and more. Review the key problems of parallelism -- including deadlocks, race conditions, and synchronization -- and discover proven techniques for avoiding or resolving them. Finally, master advanced techniques for building optimized concurrent code, including Java monitors, parallel execution of subroutines in shared memory, and parallelizing loops.

Table of Contents

Cover

Contents

Chapter 1: Foundations

The von Neumann Machine
Flynn's Taxonomy
Control-Memory Taxonomy
Speedup and Efficiency
Amdahl's Law
Scalability
Problems of Parallelism
Grain Size
Starvation
Deadlock
Flooding and Throttling
Layout
Latency
Scheduling
Programming Techniques
Chapter Wrap-up
Exercises

Chapter 2: Threads

Why is Multithreading Useful?
Overview of the Java Threads Classes
Thread: The Class Responsible for Thread Creation and Execution
Runnable: Making Threads Without Extending the Thread Class
Hello World: A First Example of Multithreading
Implementing Interfaces and Extending Classes: What's the Deal?
Concepts
A Little Bit of History
Some Definitions
Multiprogramming vs. Multitasking
o Java Support for Multiprogramming
Concurrency vs. Parallelism vs. Distribution
Threads vs. Processes
o Unix Processes
Kernel-level vs. User-level Threads
Quick Tour of Java Threads Functions
Construction
Daemon Threads
Thread Control
Very Useful Static Methods
Thread Synchronization
Cooperative Multitasking
Prioritized Scheduling
Miscellaneous Status Methods
Methods Not Covered Here
Exercises

Chapter 3: Race Conditions and Mutual Exclusion

Know Your Enemy!
Race Conditions
Egoist: A First Study in Race Conditions
A Word on Priorities
What is a Race Condition?
Race0 Class
Critical Sections and Object Locking
Race1 Class--Fixing Race0 with Synchronization
Conditions
Motivating the Need for Conditions
Key Object Methods Needed to Work with Conditions in Java
File Copying: A Producer-Consumer Example
Locks-Binary Semaphores: An Example of Using Conditions
Race2: Reworked Race1 Using Locks
Classic Synchronization Mechanisms
Counting Semaphore
Barrier
Futures
Deadlock
What is Deadlock?
How to Know When Deadlock Has Hit You?
Four Conditions of Deadlock
A Classic Example: Dining Philosophers
Chapter Wrap-up
Exercises

Chapter 4: Monitors

Real Monitors and Java Monitors
Shared Classes
Explicit Queues
Overall
Class Monitor in the Thread Package
Monitor's Methods
Interface MonitorCondition's Methods
Interface MonitorLock
Examples using Monitor Objects
SimpleFuture
SharedTableOfQueues
Implementation of Monitor, Condition, and MonitorLock
Monitor Entry and Exit
Monitor.Condition
Monitor.Lock
The Multiple Reader-Writer Monitors
Policies
Entering and Leaving the Critical Sections
The Single-Reader-Writer Monitor
The Readers-Preferred Monitor
The Writers-Preferred Monitor
The Alternating Readers-Writers Monitor
The Take-a-Number Monitor
Chapter Wrap-up
Exercises

Chapter 5: Parallel Execution of Subroutines in Shared Memory

Creating and Joining
Example: Trapezoidal Numeric Integration
o Principles
o Interface
o Code
o Discussion
RunQueue
RunQueue Methods
o Managing the created threads
o Termination
o Adjusting maxThreadsCreated
o Adjusting maxThreadsWaiting
o Adjusting waitTime
RunQueue Implementation
o Fields
o Xeqthreads
o Enqueueing Runnables
o Dequeueing Runnables
Recursive Shell Sort: RunQueues and SimpleFutures
ShellsortDC
ShellsortDC Sort class
Accumulator
Accumulator Operations
Patterns of Use of Accumulators
o Awaiting completion
o And or Or
o Associative, commutative operations
o Shared data structures
Using Accumulators
Numeric Integration
TerminationGroup
Combinatorial Search
The 0-1 Knapsack Problem
Parallel Depth-first Search for the Knapsack Problem
Knapsack2
o Constructor
o Method gen()
o The Search class
o Methods getSelected() and getProfit()
PriorityRunQueue
Branch-and-Bound with Priority Run Queues
Branch and Bound for 0-1 Knapsack
o Class Search
o Class SearchFactory
o Constructor
A Purer Branch-and-Bound 0-1 Knapsack
Chapter Wrap-up
Exercises

Chapter 6: Parallelizing Loops

Chore Graphs
Gathering Chores into Threads
Example: Warshall's Algorithm
Static Scheduling
Dynamic Scheduling
Example: Longest Common Subsequence
Example: Shell Sort
ShellsortBarrier class
Class Sort
Performance
Chapter Wrap-up
Exercises

Chapter 7: Chores

The RunDelayed Interface
Futures
FutureFactory
Chore-programming Techniques
Job Jars
Chore Graphs
Macro Dataflow
o Macro dataflow chore graphs
o Chore constructors
o Fetching operands
Flow of Control
o Changing run queues
o Switch statement
o Create a continuation object
o Create a local continuation object
Macro Dataflow Examples: Vector Addition
Continuations to Separate Operand Fetch from Operation
Static Dataflow Style and Storing Operands in Instructions
Fetching in continuations
Chore Examples: Warshall's Algorithm
WarshallDF1 and Warshall's Algorithm in Dataflow
WarshallC1 through WarshallC3: Chores, But not Dataflow
o WarshallC1
o WarshallC2
o WarshallC3
Chapter Wrap-up
Exercises

Chapter 8: Thread and Chore Synchronization

TerminationGroup
Barrier
BarrierFactory
AccumulatorFactory
Parallel Quicksort
Method sort()
QuickSortThread2
Method quicksort()
Shell Sort
Chapter Wrap-up

Chapter 9: Shared Tables of Queues

Shared Tables of Queues
Methods
Implementing Synchronizations Using a Shared Table of Queues
Named Futures
Named, Locked Records
Named Locks
Named Semaphores
Named Queues
Indexed Keys
Implementing More Synchronizations and Shared Structures
Bounded buffers
I-structures
Barriers
Reactive Objects
Communicating through a Shared Table of Queues
closure
Block
Performance
Future Queues
Methods
Implementation of FutureQueue
o Desired behavior
o States of the future queue
Example of FutureQueue: The Queued Readers-Writers Monitor
o State of the monitor
Future Tables
Chapter Wrap-up
Exercises

Chapter 10: Streams Essentials

The Streams Abstraction
Building Your Own Stream
Caesar Cipher: Very Basic Encryption
Chapter Wrap-Up
Exercises

Chapter 11: Networking

Exploring the Client Side
Services: The Internet Story
Destination Sendmail
Java Networking: Socket and InetAddress
Java packages used
The use of OOP to create the GUI
The constructor
Layouts
Event handling
Sending mail: the final frontier
Where are The Services?
A Kind and Gentle Introduction to the Server Side
Iterative Servers
Simple Messaging Architecture
The Message Class
DateService and DateClient SMA Style
Chapter Wrap-Up
Exercises

Chapter 12: Coordination

Generic Mailbox Invocations
GMI: Goals and Design Overview
Callable: An Interface for Accepting Communication
CallMessage: An Abstract Class for Marshalling and Unmarshalling!
RemoteCallServer
RemoteCallServerDispatcher
RemoteCallClient
Memo: A Remote Interface to SharedTableOfQueues
Design
MemoServer
MemoClient
Vector Inner Product
Trapezoidal Integration
Warshall's Algorithm
Chapter Wrap-up
Exercises

Index
Download the book High-Performance Java Platform Computing: Multithreaded and Networked Programming for free or read online
Read Download
Continue reading on any device:
QR code
Last viewed books
Related books
Comments (0)
reload, if the code cannot be seen