100% found this document useful (3 votes)
95 views

Instant Download Java Coding Problems: Become An Expert Java Programmer by Solving Over 200 Brand-New, Modern, Real-World Problems, 2nd Edition Anghel Leonard PDF All Chapter

expert

Uploaded by

mootineranka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
95 views

Instant Download Java Coding Problems: Become An Expert Java Programmer by Solving Over 200 Brand-New, Modern, Real-World Problems, 2nd Edition Anghel Leonard PDF All Chapter

expert

Uploaded by

mootineranka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

Java Coding Problems: Become an expert Java


programmer by solving over 200 brand-new,
modern, real-world problems, 2nd edition
Anghel Leonard
https://textbookfull.com/product/java-coding-
problems-become-an-expert-java-programmer-by-
solving-over-200-brand-new-modern-real-world-
problems-2nd-edition-anghel-leonard/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Java Coding Problems, 2nd Edition: Become an expert Java


programmer by solving over 200 brand-new, modern, real-
world problems Anghel Leonard
https://textbookfull.com/product/java-coding-problems-2nd-edition-
become-an-expert-java-programmer-by-solving-over-200-brand-new-modern-
real-world-problems-anghel-leonard/
textbookfull.com

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/

textbookfull.com

Learning Java An Introduction to Real World Programming


with Java Marc Loy

https://textbookfull.com/product/learning-java-an-introduction-to-
real-world-programming-with-java-marc-loy/

textbookfull.com

Timber Spring s Mountain Men 1st Edition Josie O Sullivan


O Sullivan Josie

https://textbookfull.com/product/timber-spring-s-mountain-men-1st-
edition-josie-o-sullivan-o-sullivan-josie-2/

textbookfull.com
Managing the Transition to IFRS Based Financial Reporting
A Practical Guide to Planning and Implementing a
Transition to IFRS or National GAAP which is Based on or
Converged with IFRS 1st Edition Lisa Weaver
https://textbookfull.com/product/managing-the-transition-to-ifrs-
based-financial-reporting-a-practical-guide-to-planning-and-
implementing-a-transition-to-ifrs-or-national-gaap-which-is-based-on-
or-converged-with-ifrs-1st-edition-lisa/
textbookfull.com

The Manhattan Job Spider Heist Thrillers 3 1st Edition


Jason Kasper

https://textbookfull.com/product/the-manhattan-job-spider-heist-
thrillers-3-1st-edition-jason-kasper/

textbookfull.com

The Scared Stiff 1st Edition Donald E Westlake

https://textbookfull.com/product/the-scared-stiff-1st-edition-donald-
e-westlake/

textbookfull.com

Music Analysis and the Body Experiments Explorations and


Embodiments N Reyland

https://textbookfull.com/product/music-analysis-and-the-body-
experiments-explorations-and-embodiments-n-reyland/

textbookfull.com

Physics and Chemistry of Classical Materials Applied


Research and Concepts 1st Edition Ewa Klodzinska (Editor)

https://textbookfull.com/product/physics-and-chemistry-of-classical-
materials-applied-research-and-concepts-1st-edition-ewa-klodzinska-
editor/
textbookfull.com
Chemical modelling. / Volume 13 Michael Springborg

https://textbookfull.com/product/chemical-modelling-volume-13-michael-
springborg/

textbookfull.com
Java Coding Problems
Second Edition

Become an expert Java programmer by solving


over 200 brand-new, modern, real-world
problems

Anghel Leonard

BIRMINGHAM—MUMBAI
Java Coding Problems

Second Edition

Copyright © 2024 Packt Publishing


All rights reserved. No part of this book may be reproduced, stored in
a retrieval system, or transmitted in any form or by any means,
without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure
the accuracy of the information presented. However, the information
contained in this book is sold without warranty, either express or
implied. Neither the author, nor Packt Publishing or its dealers and
distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information
about all of the companies and products mentioned in this book by
the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.

Senior Publishing Product Manager: Denim Pinto

Acquisition Editor – Peer Reviews: Gaurav Gavas

Project Editor: Namrata Katare

Senior Development Editor: Elliot Dallow

Copy Editor: Safis Editing


Technical Editor: Aniket Shetty

Proofreader: Safis Editing

Indexer: Rekha Nair

Presentation Designer: Ajay Patule

Developer Relations Marketing Executive: Vipanshu Parashar

First published: September 2019

Second edition: March 2024

Production reference: 1120324

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK.

ISBN 978-1-83763-394-4

www.packt.com
Contributors

About the author


Anghel Leonard is a chief technology strategist with more than 20
years of experience in the Java ecosystem. In his daily work, he is
focused on architecting and developing Java distributed applications
that empower robust architectures, clean code, and high
performance. He is passionate about coaching, mentoring, and
technical leadership.
He is the author of several books and videos and dozens of articles
related to Java technologies.
About the reviewers
George Adams is a senior software engineer at Microsoft and the
Java Champion and steering committee chair at Eclipse Adoptium.
He was a co-founder of AdoptOpenJDK in 2016 and, since then, has
led its community outreach efforts. He was instrumental in moving
the project to the Eclipse Foundation. George also contributes to both
the Homebrew project and the Node.js Foundation, where he is a
core collaborator and plays an active role in several of the
workgroups.

Ivar Grimstad is a Jakarta EE developer advocate at the Eclipse


Foundation. He is a Java Champion and JUG Leader based in
Sweden. He contributes to the Jakarta EE specifications and is the
PMC Lead for Eclipse Enterprise for Java (EE4J). He is also a
specification lead for Jakarta MVC and represents the Eclipse
Foundation on the JCP Executive Committee. Ivar is also involved in
a wide range of open-source projects and communities and is a
frequent speaker at international developer conferences.
Join our community on Discord
Join our community’s Discord space for discussions with the author
and other readers:
https://discord.gg/8mgytp5DGQ
Contents
Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
1. Text Blocks, Locales, Numbers, and Math
Problems
1. Creating a multiline SQL, JSON, and HTML string
Before JDK 8
Starting with JDK 8
Introducing text blocks (JDK 13/15)
Hooking text blocks syntax
2. Exemplifying the usage of text block delimiters
3. Working with indentation in text blocks
Shifting the closing delimiter and/or the content
Using indentation methods
4. Removing incidental white spaces in text blocks
5. Using text blocks just for readability
6. Escaping quotes and line terminators in text blocks
7. Translating escape sequences programmatically
8. Formatting text blocks with variables/expressions
9. Adding comments in text blocks
10. Mixing ordinary string literals with text blocks
11. Mixing regular expression with text blocks
12. Checking if two text blocks are isomorphic
13. Concatenating strings versus StringBuilder
JDK 8
JDK 11
14. Converting int to String
15. Introducing string templates
What’s a string template?
The STR template processor
The FMT template processor
The RAW template processor
16. Writing a custom template processor
17. Creating a Locale
18. Customizing localized date-time formats
19. Restoring Always-Strict Floating-Point semantics
20. Computing mathematical absolute value for int/long
and result overflow
21. Computing the quotient of the arguments and result
overflow
22. Computing the largest/smallest value that is
less/greater than or equal to the algebraic quotient
23. Getting integral and fractional parts from a double
24. Testing if a double number is an integer
25. Hooking Java (un)signed integers in a nutshell
26. Returning the flooring/ceiling modulus
27. Collecting all prime factors of a given number
28. Computing the square root of a number using the
Babylonian method
29. Rounding a float number to specified decimals
30. Clamping a value between min and max
31. Multiply two integers without using loops,
multiplication, bitwise, division, and operators
32. Using TAU
What is TAU?
33. Selecting a pseudo-random number generator
Choosing an algorithm by name
Choosing an algorithm by property
34. Filling a long array with pseudo-random numbers
35. Creating a stream of pseudo-random generators
36. Getting a legacy pseudo-random generator from new
ones of JDK 17
37. Using pseudo-random generators in a thread-safe
fashion (multithreaded environments)
Summary
2. Objects, Immutability, Switch Expressions, and Pattern Matching
Problems
38. Explain and exemplifying UTF-8, UTF-16, and UTF-32
Introducing ASCII encoding scheme (or single-byte
encoding)
Introducing multi-byte encoding
Unicode
Java and Unicode
JDK 18 defaults the charset to UTF-8
39. Checking a sub-range in the range from 0 to length
40. Returning an identity string
41. Hooking unnamed classes and instance main methods
42. Adding code snippets in Java API documentation
Adding attributes
Using markup comments and regions
Highlighting
Linking
Modifying the code’s text
Using external snippets
Regions in external snippets
43. Invoking default methods from Proxy instances
JDK 8
JDK 9+, pre-JDK 16
JDK 16+
44. Converting between bytes and hex-encoded strings
JDK 17+
45. Exemplify the initialization-on-demand holder design
pattern
Static vs. non-static blocks
Nested classes
Tackling the initialization-on-demand holder design
pattern
JDK 16+
46. Adding nested classes in anonymous classes
JDK 16+
47. Exemplify erasure vs. overloading
Erasure in a nutshell
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Erasure of generic types
Erasure and bridge methods
Type erasure and heap pollution
Polymorphic overloading in a nutshell
Erasure vs. overloading
48. Xlinting default constructors
49. Working with the receiver parameter
50. Implementing an immutable stack
51. Revealing a common mistake with Strings
52. Using the enhanced NullPointerException
WARNING 1! NPE when calling an instance method via
a null object
WARNING 2! NPE when accessing (or modifying) the
field of a null object
WARNING 3! NPE when null is passed in the method
argument
WARNING 4! NPE when accessing the index value of a
null array/collection
WARNING 5! NPE when accessing a field via a getter
53. Using yield in switch expressions
54. Tackling the case null clause in switch
55. Taking on the hard way to discover equals()
56. Hooking instanceof in a nutshell
57. Introducing pattern matching
The scope of binding variables in pattern matching
Guarded patterns
Type coverage
Current status of pattern matching
58. Introducing type pattern matching for instanceof
59. Handling the scope of a binding variable in type
patterns for instanceof
60. Rewriting equals() via type patterns for instanceof
61. Tackling type patterns for instanceof and generics
62. Tackling type patterns for instanceof and streams
63. Introducing type pattern matching for switch
64. Adding guarded pattern labels in switch
65. Dealing with pattern label dominance in switch
66. Dealing with completeness (type coverage) in pattern
labels for switch
67. Understanding the unconditional patterns and nulls in
switch expressions
Summary
3. Working with Date and Time
Problems
68. Defining a day period
Before JDK 16
JDK 16+
69. Converting between Date and YearMonth
70. Converting between int and YearMonth
71. Converting week/year to Date
72. Checking for a leap year
73. Calculating the quarter of a given date
74. Getting the first and last day of a quarter
75. Extracting the months from a given quarter
76. Computing pregnancy due date
77. Implementing a stopwatch
78. Extracting the count of milliseconds since midnight
79. Splitting a date-time range into equal intervals
80. Explaining the difference between Clock.systemUTC()
and Clock.systemDefaultZone()
81. Displaying the names of the days of the week
82. Getting the first and last day of the year
83. Getting the first and last day of the week
84. Calculating the middle of the month
85. Getting the number of quarters between two dates
86. Converting Calendar to LocalDateTime
87. Getting the number of weeks between two dates
Summary
4. Records and Record Patterns
Problems
88. Declaring a Java record
89. Introducing the canonical and compact constructors for
records
Handling validation
Reassigning components
Defensive copies of the given components
90. Adding more artifacts in a record
91. Iterating what we cannot have in a record
A record cannot extend another class
A record cannot be extended
A record cannot be enriched with instance fields
A record cannot have private canonical constructors
A record cannot have setters
92. Defining multiple constructors in a record
93. Implementing interfaces in records
94. Understanding record serialization
How serialization/deserialization works
Serializing/deserializing gacContainer (a typical Java
class)
Deserializing a malicious stream
Serializing/deserializing gacContainerR (a Java record)
Deserializing a malicious stream
Refactoring legacy serialization
95. Invoking the canonical constructor via reflection
96. Using records in streams
97. Introducing record patterns for instanceof
Nested records and record patterns
98. Introducing record patterns for switch
99. Tackling guarded record patterns
100. Using generic records in record patterns
Type argument inference
Type argument inference and nested records
101. Handling nulls in nested record patterns
102. Simplifying expressions via record patterns
103. Hooking unnamed patterns and variables
Unnamed patterns
Unnamed variables
In a catch block
In a for loop
In an assignment that ignores the result
In try-with-resources
In lambda expressions
104. Tackling records in Spring Boot
Using records in controllers
Using records with templates
Using records for configuration
Record and dependency injection
105. Tackling records in JPA
DTO via record constructor
DTO via record and JPA constructor expression
DTO via record and result transformer
DTO via record and JdbcTemplate
Team up Java records and @Embeddable
106. Tackling records in jOOQ
Summary
5. Arrays, Collections, and Data Structures
Problems
107. Introducing parallel computations with arrays
108. Covering the Vector API’s structure and terminology
The vector element type
The vector shape
The vector species
Vector lanes
Vector operations
Creating vectors
Creating vectors of zeros
Creating vectors of the same primitive value
Creating vectors from Java arrays
Creating vectors from memory segments
109. Summing two arrays via the Vector API
110. Summing two arrays unrolled via the Vector API
111. Benchmarking the Vector API
112. Applying the Vector API to compute FMA
113. Multiplying matrices via the Vector API
114. Hooking the image negative filter with the Vector API
115. Dissecting factory methods for collections
Factory methods for maps
Factory methods for lists
Factory methods for sets
116. Getting a list from a stream
117. Handling map capacity
118. Tackling Sequenced Collections
Applying the Sequenced Collections API to lists
Applying the Sequenced Collections API to
ArrayList and LinkedList
Applying the Sequenced Collections API to sets
Applying the Sequenced Collections API to
HashSet
Applying the Sequenced Collections API to
LinkedHashSet
Applying the Sequenced Collections API to TreeSet
Applying the Sequenced Collections API to maps
Applying the Sequenced Collections API to
LinkedHashMap
Applying the Sequenced Collections API to
SortedMap (TreeMap)
119. Introducing the Rope data structure
Implementing indexAt(Node node, int index)
Implementing concat(Node node1, Node node2)
Implementing insert(Node node, int index, String str)
Implementing delete(Node node, int start, int end)
Implementing split(Node node, int index)
120. Introducing the Skip List data structure
Implementing contains(Integer data)
Implementing insert(Integer data)
Implementing delete(Integer data)
121. Introducing the K-D Tree data structure
Inserting into a K-D Tree
Finding the nearest neighbor
122. Introducing the Zipper data structure
123. Introducing the Binomial Heap data structure
Implementing insert(int key)
Implementing findMin()
Implementing extractMin()
Implementing decreaseKey(int key, int newKey)
Implementing delete(int key)
Implementing unionHeap(BinomialHeap heap)
124. Introducing the Fibonacci Heap data structure
125. Introducing the Pairing Heap data structure
126. Introducing the Huffman Coding data structure
Encoding the string
Decoding the string
127. Introducing the Splay Tree data structure
128. Introducing the Interval Tree data structure
Implementing insert(Interval interval)
129. Introducing the Unrolled Linked List data structure
130. Implementing join algorithms
Nested Loop Join
Hash Join
Sort Merge Join
Summary
6. Java I/O: Context-Specific Deserialization Filters
Problems
131. Serializing objects to byte arrays
132. Serializing objects to strings
133. Serializing objects to XML
134. Introducing JDK 9 deserialization filters
Pattern-based filters
Applying a pattern-based filter per application
Applying a pattern-based filter to all applications in
a process
ObjectInputFilter-based filters
135. Implementing a custom pattern-based
ObjectInputFilter
136. Implementing a custom class ObjectInputFilter
137. Implementing a custom method ObjectInputFilter
138. Implementing a custom lambda ObjectInputFilter
139. Avoiding StackOverflowError at deserialization
140. Avoiding DoS attacks at deserialization
141. Introducing JDK 17 easy filter creation
142. Tackling context-specific deserialization filters
Applying a Filter Factory per application
Applying a Filter Factory to all applications in a process
Applying a Filter Factory via ObjectInputFilter.Config
Implementing a Filter Factory
143. Monitoring deserialization via JFR
Summary
7. Foreign (Function) Memory API
Problems
144. Introducing Java Native Interface (JNI)
Generating the header (.h) file
Implementing the modern_challenge_Main.cpp
Compiling the C source code
Generating the native shared library
Finally, run the code
145. Introducing Java Native Access (JNA)
Implementing the .cpp and .h files
Compiling the C source code
Generating the native shared library
Finally, run the code
146. Introducing Java Native Runtime (JNR)
147. Motivating and introducing Project Panama
148. Introducing Panama’s architecture and terminology
149. Introducing Arena and MemorySegment
Introducing memory layouts (ValueLayout)
Allocating memory segments of value layouts
Setting/getting the content of a memory segment
Working with Java strings
150. Allocating arrays into memory segments
151. Understanding addresses (pointers)
152. Introducing the sequence layout
Introducing PathElement
Introducing VarHandle
Putting PathElement and VarHandle together
Working with nested sequence layouts
153. Shaping C-like structs into memory segments
Introducing StructLayout
154. Shaping C-like unions into memory segments
Introducing UnionLayout
155. Introducing PaddingLayout
Hooking size, alignment, stride, and padding
Hooking size
Hooking alignment
Hooking stride
Hooking padding
Adding implicit extra space (implicit padding) to
validate alignment
Adding explicit extra space (explicit padding) to
validate alignment
156. Copying and slicing memory segments
Copying a segment
Copying a part of the segment into another segment
(1)
Copying a segment into an on-heap array
Copying an on-heap array into a segment
Copying a part of the segment into another segment
(2)
Slicing a segment
Using asOverlappingSlice()
Using segmentOffset()
157. Tackling the slicing allocator
158. Introducing the slice handle
159. Introducing layout flattening
160. Introducing layout reshaping
161. Introducing the layout spreader
162. Introducing the memory segment view VarHandle
163. Streaming memory segments
164. Tackling mapped memory segments
165. Introducing the Foreign Linker API
166. Calling the sumTwoInt() foreign function
167. Calling the modf() foreign function
168. Calling the strcat() foreign function
169. Calling the bsearch() foreign function
170. Introducing Jextract
171. Generating native binding for modf()
Summary
8. Sealed and Hidden Classes
Problems
172. Creating an electrical panel (hierarchy of classes)
173. Closing the electrical panel before JDK 17
Applying the final modifier
Defining package-private constructors
Declaring classes/interfaces as non-public
Throwing everything in a module
Conclusion
174. Introducing JDK 17 sealed classes
175. Introducing the permits clause
Working with sealed classes in separate sources (same
package)
Working with sealed classes in separate packages
176. Closing the electrical panel after JDK 17
177. Combining sealed classes and records
178. Hooking sealed classes and instanceof
179. Hooking sealed classes in switch
180. Reinterpreting the Visitor pattern via sealed classes
and type pattern matching for switch
181. Getting info about sealed classes (using reflection)
182. Listing the top three benefits of sealed classes
183. Briefly introducing hidden classes
184. Creating a hidden class
Summary
9. Functional Style Programming – Extending APIs
Problems
185. Working with mapMulti()
186. Streaming custom code to map
187. Exemplifying a method reference vs. a lamda
Scenario 1: Calling printReset()
Scenario 2: Calling static printNoReset()
Conclusion
188. Hooking lambda laziness via Supplier/Consumer
189. Refactoring code to add lambda laziness
Fixing in imperative fashion
Fixing in functional fashion
190. Writing a Function<String, T> for parsing data
191. Composing predicates in a Stream’s filters
192. Filtering nested collections with Streams
193. Using BiPredicate
194. Building a dynamic predicate for a custom model
195. Building a dynamic predicate from a custom map of
conditions
196. Logging in predicates
197. Extending Stream with containsAll() and containsAny()
Exposing containsAll/Any() via a custom interface
Exposing containsAll/Any() via an extension of Stream
198. Extending Stream with removeAll() and retainAll()
Exposing removeAll()/retainAll() via a custom interface
Exposing removeAll/retainAll() via an extension of
Stream
199. Introducing stream comparators
Sorting via natural order
Reversing the natural order
Sorting and nulls
Writing custom comparators
200. Sorting a map
201. Filtering a map
202. Creating a custom collector via Collector.of()
Writing a custom collector that collects into a TreeSet
Writing a custom collector that collects into a
LinkedHashSet
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Writing a custom collector that excludes elements of
another collector
Writing a custom collector that collects elements by
type
Writing a custom collector for SplayTree
203. Throwing checked exceptions from lambdas
204. Implementing distinctBy() for the Stream API
205. Writing a custom collector that takes/skips a given
number of elements
206. Implementing a Function that takes five (or any other
arbitrary number of) arguments
207. Implementing a Consumer that takes five (or any
other arbitrary number of) arguments
208. Partially applying a Function
Summary
10. Concurrency – Virtual Threads and Structured Concurrency
Problems
209. Explaining concurrency vs. parallelism
210. Introducing structured concurrency
211. Introducing virtual threads
What’s the problem with platform (OS) threads?
What are virtual threads?
Creating a virtual thread
How many virtual threads we can start
Backward compatibility
Avoiding fake conclusions (potentially myths)
212. Using the ExecutorService for virtual threads
213. Explaining how virtual threads work
Capturing virtual threads
Pinning virtual threads
214. Hooking virtual threads and sync code
215. Exemplifying thread context switching
Example 1
Example 2
Example 3
216. Introducing the ExecutorService invoke all/any for
virtual threads – part 1
Working with invokeAll()
Working with invokeAny()
217. Introducing the ExecutorService invoke all/any for
virtual threads – part 2
218. Hooking task state
219. Combining newVirtualThreadPerTaskExecutor() and
streams
220. Introducing a scope object (StructuredTaskScope)
ExecutorService vs. StructuredTaskScope
221. Introducing ShutdownOnSuccess
222. Introducing ShutdownOnFailure
223. Combining StructuredTaskScope and streams
224. Observing and monitoring virtual threads
Using JFR
Using Java Management Extensions (JMX)
Running 10,000 tasks via the cached thread pool
executor
Running 10,000 tasks via the fixed thread pool
executor
Running 10,000 tasks via the virtual thread per task
executor
Summary
11. Concurrency ‒ Virtual Threads and Structured Concurrency:
Diving Deeper
Problems
225. Tackling continuations
Introducing continuations
Continuations and virtual threads
226. Tracing virtual thread states and transitions
NEW
STARTED
RUNNING
PARKING
PARKED/PINNED
YIELDING
RUNNABLE
TERMINATED
227. Extending StructuredTaskScope
228. Assembling StructuredTaskScope
229. Assembling StructuredTaskScope instances with
timeout
230. Hooking ThreadLocal and virtual threads
231. Hooking ScopedValue and virtual threads
Thread-local variables’ shortcomings
Introducing scoped values
232. Using ScopedValue and executor services
233. Chaining and rebinding scoped values
Changing scoped values
Rebinding scoped values
234. Using ScopedValue and StructuredTaskScope
235. Using Semaphore instead of Executor
236. Avoiding pinning via locking
237. Solving the producer-consumer problem via virtual
threads
238. Solving the producer-consumer problem via virtual
threads (fixed via Semaphore)
239. Solving the producer-consumer problem via virtual
threads (increase/decrease consumers)
240. Implementing an HTTP web server on top of virtual
threads
241. Hooking CompletableFuture and virtual threads
242. Signaling virtual threads via wait() and notify()
Summary
12. Garbage Collectors and Dynamic CDS Archives
Problems
243. Hooking the garbage collector goal
244. Handling the garbage collector stages
245. Covering some garbage collector terminology
Epoch
Single and multiple passes
Serial and parallel
Stop-the-World (STW) and concurrent
Live set
Allocation rate
NUMA
Region-based
Generational garbage collection
246. Tracing the generational GC process
247. Choosing the correct garbage collector
248. Categorizing garbage collectors
Serial garbage collector
Parallel garbage collector
Garbage-First (G1) collector
Z Garbage Collector (ZGC)
Shenandoah Garbage Collector
Concurrent Mark Sweep (CMS) collector (deprecated)
249. Introducing G1
Design principles
250. Tackling G1 throughput improvements
Delaying the start of the Old generation
Focusing on easy pickings
Improving NUMA-aware memory allocation
Parallelized full-heap collections
Other improvements
251. Tackling G1 latency improvements
Merge parallel phases into a larger one
Reduction of metadata
Better work balancing
Better parallelization
Better reference scanning
Other improvements
252. Tackling G1 footprint improvements
Maintain only the needed metadata
Release memory
253. Introducing ZGC
ZGC is concurrent
ZGC and colored pointers
ZGC and load barriers
ZGC is region-based
254. Monitoring garbage collectors
255. Logging garbage collectors
256. Tuning garbage collectors
How to tune
Tuning the serial garbage collector
Tunning the parallel garbage collector
Tuning the G1 garbage collector
Tuning Z Garbage Collector
Tuning Metaspace (Metadata space)
257. Introducing Application Class Data Sharing (AppCDS,
or Java’s Startup Booster)
Tackling a JDK class data archive
JDK 10/JDK 11
JDK 12+
Tackling application class data archive
Before JDK 13
JDK 13+
JDK 19+
Summary
13. Socket API and Simple Web Server
Problems
258. Introducing socket basics
259. Introducing TCP server/client applications
Blocking vs. non-blocking mechanisms
260. Introducing the Java Socket API
Introducing NetworkChannel
Tackling socket options
261. Writing a blocking TCP server/client application
Writing a single-thread blocking TCP echo server
Creating a new server socket channel
Configuring the blocking mechanism
Setting server socket channel options
Binding the server socket channel
Random documents with unrelated
content Scribd suggests to you:
when Tom once more popped his left on the mouth heavily,
and got away. He played round his man and at last sent home
another left-hander on the left eye—​a cross hit. Poulson just
reached his jaw with his right, and Tom got down.
78.—​Tom made play with his left on the right ogle, and
avoided the return. Poulson persevered, and at last Tom got
down in his corner.
79.—​Poulson dashed in his right on the nose, but not very
heavily; Sayers returned on the right gazer, and napped a
heavy right-hander on the cheek, from the effect of which he
went down weak.
80.—​Tom steadied himself, crept close, and popped his left
on the left eye. Poulson rushed at him, and heavy counter-
hits were exchanged on the jaw, both coming to the ground
side by side.
81.—​Tom missed two attempts to deliver, and received
another heavy thwack on the bread-basket. Heavy exchanges
ensued in favour of Poulson, who was always best at close
quarters, and Sayers got down.
82.—​Tom came up a little stronger, and let go his left, but
not heavily, on the right cheek. Poulson tried a return, but
Tom, who gradually retreated, propped him as he came in, on
the right eye and nose. Poulson, determined if possible, to
make a decided turn in his favour, persevered, and some
rattling ding-dong fighting took place, each getting it heavily
on the dial, and in the end both were down.
83.—​Both looked the worse for the last round, but
Poulson’s left eye was fast following suit with his right, and it
was evident to all that if Sayers kept away it was a mere
question of time. Sayers feinted, put in his double very neatly
on the mouth, and then got a hot one on the left cheek. Good
exchanges at close quarters followed, in which Poulson’s
visitations to Tom’s snout were anything but agreeable, while
Tom was busy on the right eye. This was another ding-dong
round, and astonished every one after the men had fought so
long. In the end Sayers got down, and Poulson fell on his
knees at his side.
84.—​Tom’s double was once more successful, and he got
well on Harry’s smeller. Poulson once more reached the left
side of the nut, just by the ear, and Tom fell.
85.—​Poulson led off with his left, getting well on Tom’s
nose. Good counter-hits followed, Tom getting it on the
mouth, and Harry on the left eye. Poulson now dashed in, but
got one on the right eye; he, however, nailed Tom on the
right ear, drawing claret. Another desperate rally followed, in
which Jack was as good as his master, and in the end Sayers
got down. Two hours and thirty minutes had now elapsed.
86.—​Poulson dashed in, but Sayers stepped nimbly back,
propping him as he came on the left eye. Harry at last made
his right on the left ear, and Tom got down.
87.—​Poulson again rushed in, but Sayers, after propping
him over the right eye, dropped. Another claim of foul not
allowed.
88.—​Tom tried his left, but was short; Poulson then rattled
in, caught him on the left side of his knowledge-box, and Tom
dropped.
89.—​Poulson, after being short with his one, two, made his
right on the ribs, and Tom fell.
90.—​Poulson again hit out of distance; he persevered, and
eventually nailed Tom slightly on the nozzle, and that hero
wisely got down, by way of a rest, finding that Harry was still
dangerous at close quarters.
91.—​Tom stopped Harry with great neatness, and then
planted his left on the throat; heavy exchanges followed in
favour of Poulson, who again reached Tom’s left ear very
severely, drawing more of the Burgundy, and Tom fell very
weak.
92.—​Tom, who staggered up, received a heavy one from
Harry’s right on the brow, and got down.
93.—​Neither very ready at the call of “Time,” but Tom
slowest; he nevertheless came up steady, and, as Poulson
rushed in, planted his left very heavily, first on the right eye
and then on the nose, and got away, followed by Poulson,
who forced the fighting. Heavy exchanges followed, Harry on
the ribs and Tom on the forehead, and Tom down.
94.—​Poulson for the first time got on to Tom’s right eye,
but not heavily; he then popped his right on the ear, and also
on the ribs very heavily, staggering Tom, who evidently
winced under the latter visitation. Tom, however shook
himself together, and some sharp exchanges took place,
which ended in Sayers dropping to avoid a fall.
95.—​Poulson’s right neatly stopped. He tried again with a
rush, but Tom cleverly ducked and got away. Poulson followed
him up, and napped a sharp reminder over the right brow;
Poulson returned on the chest, and Tom got down.
96.—​After some harmless exchanges, Sayers got down,
amidst the groans of the Nottingham party.
97.—​Poulson was again neatly stopped, and Tom returned
heavily on the mouth, turning on the main once more.
Poulson made his right on the ribs, and then on the left
cheek, and, after one or two harmless passes, Tom got down.
98.—​Sayers put in his double on the throat, and Poulson
rushed to a close, and, after a brief struggle, Sayers fell;
Poulson again, and in the most manly way, avoiding failing on
him.
99.—​Tom, evidently the best man, dodged, and put in his
left on the side of Poulson’s head; Harry wide of the mark
with his return. Tom came again, dodged him, and whack
went his left on the smelling-bottle. Slight exchanges
followed, and then Poulson, as Sayers was retreating, caught
him a heavy right-hander on the jaw which knocked him
down.
100.—​The Poulsonians anxious for the call of “Time;” but
to their surprise Tom came up quite steady. He dodged his
man, popped in his double on the nose and left peeper
without a return, and then on the throat, and in getting back
fell.
101.—​Poulson, nearly blind, dashed in with determination,
and heavy counter-hits were exchanged, Tom getting well on
the mouth and Harry on the nose, and Sayers slipped down.
Three hours had now elapsed.
102.—​Sayers drew a fresh supply of the ruby from Harry’s
right cheek, and, in retreating, fell. Another claim of foul.
103.—​Poulson went in and made his right on the side of
Tom’s head. Tom retreated, advanced, making his usual feint,
but, on seeing Poulson coming at him, he tried to get back,
and, his legs slipping apart, he could not get himself into a
defensive position, and fell. Another claim of foul was here
made; but the referee, who had not seen the round, owing to
the interposition of the bodies of the seconds and backers of
Poulson, pronounced “fair;” and in his decision we decidedly
concur, as, in our opinion, the fall on the part of Sayers was
entirely unpremeditated and accidental. It was for some time
before order was restored; and the delay was of the greatest
advantage to Sayers, while it had an opposite effect on
Poulson, whose left eye was now all but closed.
104.—​Tom came up gaily, dodged his man, who came
towards him, and then nailed him heavily on the proboscis
and left peeper. A close followed, and Sayers got down.
105.—​Slight exchanges, in which no damage was done,
and Sayers slipped down.
106.—​Poulson dashed in to make a last effort, and heavy
counter-hits were exchanged. Sayers caught him on the left
eye, and received a heavy rib-bender and then a crack on the
left ear, whereupon he dropped.
107.—​Sayers, bleeding from the left ear, came up slowly
and feinted in his usual style; caught Harry on the right eye,
and then on the mark. Poulson popped his right heavily on
the ribs, and another give-and-take rally followed, at the end
of which Sayers, who was still weak on his legs, got down.
108.—​Poulson’s face was now much swollen and there was
scarcely a glimmer from his left peeper. He was, however, still
strong as ever on his pins. He rushed in, knowing he had no
time to spare, and caught Tom heavily with his right on the
left ear. Exchanges followed, Sayers being straightest. Poulson
bored in, and got home heavily with his right on the ribs,
when Tom delivered his left heavily on the jaw, and knocked
him down.
109, and last.—​The last blow had evidently been a settler
for the gallant Poulson: he came up slowly and all abroad.
The game fellow tried once more to effect a lodgement, but
missed, his head came forward and Tom delivered the coup
de grâce by a heavy right-hander on the jaw, which again
knocked the veteran off his legs, and, on being taken up, he
was found to be deaf to the call of “Time.” He recovered in a
few minutes, and shed bitter tears of disappointment at the
unsatisfactory and unexpected termination of his labours.
Sayers walked to a public house adjoining the field of battle,
and of course was vociferously congratulated by his friends
and admirers upon his triumphant success. Poulson was also
conveyed to the public-house, and, after taking some
refreshment, became himself. He was quite blind, and his
mug otherwise much battered, but beyond this had sustained
no serious injuries. Sayers complained a good deal of the
punishment about his body, and the repeated visitations to
the side of his head, but of course the fact of his being the
winner went far to allay the physical suffering he endured.
Both were enabled to return to town in the same train with
their friends, and arrived at their respective houses about
half-past nine o’clock. The fight lasted three hours and eight
minutes.
Remarks.—​Owing to the minute details which we have given
of all the material incidents in this really extraordinary battle,
we may spare our readers the trouble of reading many
observations upon the respective merits of the men, of which
the account of the different rounds will have enabled them to
form as correct an opinion as ourselves. Tom Sayers, by his
quickness on his legs, his steadiness and excellent judgment,
not only astonished his adversary and his backers, but
completely took his own friends by surprise. He had evidently
much improved, in every possible way, since his defeat by Nat
Langham. Great fault was found with him for his too constant
resort to the dropping system; but for this he had every
excuse. He scarcely ever went down without having had a
bustling round, and once only during the battle did we
observe anything at which an impartial man would cavil. This
was at a period in the middle of the fight when he was
extremely weak, and at the time no appeal was made by the
friends of Poulson. It must be taken into consideration that
Tom was anything but himself, and the ground was far from
favourable for keeping on his legs and getting out of the
reach of his weighty and powerful adversary. It has been
urged that the ground was as much against Poulson as
Sayers; but this was hardly so. Poulson is a steady ding-dong
fighter, of the squarest build, does not depend much on his
defensive tactics, and makes little use of his legs; while Tom
had to be continually jumping back, and, when opposed to
such superior weight, would of course find proportionate
difficulty in keeping on his pins. Indeed, many times when he
fell he came to the ground with such a “thud” as must have
shaken a good deal of his strength out of him. We are aware
that since the match had been made many things had
occurred to harass Tom’s mind, and that he had pecuniary
difficulties to contend with which, we trust, will not exist in
future matches; and this, again, must be taken into
consideration. He does not want for friends, and, we doubt
not, with steadiness and good conduct, will find himself on
the high road to prosperity. Of Harry Poulson’s gallantry and
manliness we cannot say too much. He fought from first to
last in a game, straightforward manner, with an evident
determination to do his best to win in a fair and honourable
way. He scorned to take advantage of many opportunities of
falling on his man, when he might have done so with perfect
fairness, and otherwise comported himself in a manner as
reflects the very highest credit upon his character as a man,
and a demonstrator of the noble art of self-defence. Although
evidently annoyed at being unable to get home as he
expected, he still never allowed his temper to get the better
of him; and often when Tom, from his shifty tactics, evaded
what had been intended as a finisher, he stood and shook his
head at him, as much as to say it was too bad, but not once
did he allow a harsh or angry expression to escape him. He is
truly one of the gamest of the game; but he is too slow, and
depends too much on his right hand, to have much chance of
success against a really finished boxer. We do not consider
that his age had anything to do with his defeat, for he is as
fresh as most London boxers who are ten years his juniors.
His bravery and universal good conduct cannot but secure
him the respect and support of all admirers of such good
qualities.

The conquest of Poulson was unquestionably the


greatest achievement of Sayers’s pugilistic career. He
was now established as a man with whom the men
under 12 stone on the boxing list must not meddle;
at any rate, none other were likely to get backers
against him.
From this period the name of Tom Sayers mixes
itself with every question of the belt and the
Championship.
In the year 1855, a proposition was set on foot by
a number of patrons of the Ring, to raise, by
subscription, a sum of money to purchase a belt of
greater intrinsic value than anything of the kind
previously presented, in lieu of the belt which had
“gone astray” during the squabbles between
Bendigo, Caunt, and the Tipton Slasher. Lists were
opened, and before long a sum of nearly £100 was
collected. To Mr. Hancock, of New Bond Street, was
entrusted the manufacture of the trophy, and from
that gentleman’s establishment was produced the
elegant badge of the highest fistic honours which
Tom Sayers so well and so worthily won. On the belt
being ordered, the committee who undertook its
management issued the following as the conditions
on which it should be held: “That it should not be
handed over to any person claiming the
Championship until he had proved his right to it by a
fight; that any pugilist having held it against all
comers for three years, without a defeat, should
become its absolute possessor; that the holder
should be bound to meet every challenger of any
weight who should challenge him for the sum of
£200 a side, within six months after the issue of such
challenge, within the three years; that he should not
be bound to fight for less than £200 a side; that at
the final deposit for every match within the three
years the belt should be delivered up to the
committee until after the battle; and, finally, that on
the belt being given to the winner of any Champion-
fight, he should deposit such security as should be
deemed necessary in the hands of the committee to
ensure the above regulations being carried out.”
No sooner did it become known that the belt was
ready for whosoever could win it, than there was a
general stirring up of the dormant energies of the big
men who had retired, or thought to be about to
retire, from the Ring. Harry Broome shook himself
together; the Tipton Slasher roused him from his lair;
Tom Paddock’s hair stood on end between hope and
fear of disappointment; while Aaron Jones, who
about this time (1855) had fought the second of two
tremendous battles with Paddock, and, though
defeated, had entirely removed any impressions as
to his want of pluck caused by his battles with Harry
Orme, also pricked up his ears, and issued a defiant
grunt. The only man among the recent combatants
for Champion’s honours who made no sign was Harry
Orme, who was content to rest upon his well-earned
reputation. At first it was thought there would not be
found a man sufficiently venturous to tackle the
“Ould Tipton,” but this was soon seen to be a fallacy;
for not one only, but each and every of the aspirants
sent out a defiance to the crooked-legged hero of
the hardware districts. The first cartel that reached
him was that of Aaron Jones, and with him
preliminaries were at once arranged.
The challenges of Broome and Paddock arriving
afterwards, the Slasher informed them that they
must wait the issue of the struggle with Jones.
Broome and Paddock seemed both disinclined to wait
for this event, and neither was desirous of
postponing his claims to those of his co-challenger,
and, as a natural consequence, a good deal of
badinage took place between them, which ended in
their being matched for £200 a side, to ascertain
which should have the preference. While they were
in training Aaron Jones was compelled to forfeit to
the Tipton Slasher, through meeting with an accident
during his training; so that there appeared a clear
course for the winner.
The fight between Broome and Paddock took
place on the 19th of May, 1856, and was won by
Tom Paddock with ease in 51 rounds, and 63
minutes, it being at once apparent that, though
Harry Broome had all the will and the courage to do
deeds of valour, the power had deserted him, and he
had become prematurely old and stale. (See page
294.)
Soon after Paddock’s defeat of Broome, Paddock
obtained the acme of his desires—​viz., a match with
his old opponent, the Slasher; but when £80 a side
had been staked Master Tom allowed his temper to
get the better of his judgment, and, having offended
his best friends, had to forfeit through a scarcity of
“ochre.” This was not only a disappointment to
himself, but also to his opponent, who was thus
foiled in his efforts to get hold of the belt, which
could not be obtained without a mill, and which he
had made sure of winning from Tom Paddock. Just
previous to this mishap Jones had recovered from his
accident, and, to the surprise of all, had been
matched with the “coming man,” Tom Sayers; so that
even here the “Old’un” was again done out of an
opponent, and the belt still remained in abeyance, to
abide the issue between Sayers and Jones, the
winner to meet the ponderous Tipton for the coveted
trophy. This fight, which took place on the banks of
the Medway, on the 19th February, 1857, we now
propose to narrate.
Owing to the puritanical persecution to which the
Ring had been for some time subjected, a line of
country had to be selected which had for a long time
been untried, so that there was every prospect of
matters being adjusted in that quarter without let or
hindrance. Although bills were circulated, stating that
a train would leave the Great Northern Station at
King’s Cross on Tuesday at nine o’clock, it was at the
eleventh hour considered that the locality would on
the present occasion be too “warm,” and therefore,
an alteration was deemed prudent. This alteration
could not be made public at so late a period, and it
was only those who happened to consult the initiated
at the benefit of the Pugilistic Benevolent
Association, on the previous Monday evening, who
got a due to the real state of the case. The
consequence was that on Tuesday morning, at the
Fenchurch Street Station, there were at the utmost
180 persons, including a considerable number of
patricians and a very small proportion of the
professors of the noble art, while of the “roughs” and
other noisy demonstrators there was an almost total
absence. These gentry and some few unfortunates of
the higher class hastened to the Great Northern
terminus at the hour named in the handbills, and
great was their disappointment, and loud their
indignation, at finding themselves sold.
The start from Fenchurch Street took place at
eight o’clock precisely, and by nine o’clock Tilbury
was reached, where all at once embarked in a vessel
provided for the purpose, and by twenty minutes to
ten were safely on board, and, greatly to the credit
of the managers of the expedition, a start was at
once effected. In order to throw dust in the eyes of
the Blues, it was determined to proceed straight to
the mouth of the river; and, in the face of a stiff gale
from E.N.E., the journey to the Nore was effected in
excellent style. The lumpy water in this locality had,
as may be imagined, a most unpleasant effect upon
many of the voyagers, whose stomachs,
unaccustomed to salt water, and anything but
improved in tone by their nocturnal vigils (as they
had sat up all night in order to be early in the
morning), were turned inside out; and the
consequence was that swabs and buckets of water
were in strong demand. After about an hour’s tossing
among the billows, “’bout ship” was the cry, the river
was re-entered, and the vessel sped homewards until
a spot was reached not far from Canvey Island,
where Freeman and the Tipton Slasher fought. With
some difficulty a landing was effected, and Tom
Oliver, Tom Callas, Puggy White, &c. proceeded to
form the lists, although it was not without
extraordinary exertions that anything like a
favourable spot could be found, and even this was
rough and extremely uneven, from the late heavy
weather. Numerous were the mishaps of the
company on landing, but by no means equal to those
they experienced on attempting to regain the vessel
after the battle was over, when thick darkness
overspread the land, and led many an unwary
traveller into mud and mire of the most consistent
character. The ring was pitched by half-past twelve
o’clock, and a tolerable outer ring was established;
but, as usual when the attendance is small, the
difficulty of preserving this outer circle intact was
very great, and towards the close of the fight,
notwithstanding the exertions of some of the ring-
keepers, the spectators crowded close to the ring,
but, fortunately, did not disturb the ropes and stakes.
The combatants, who had made a sort of demi-
toilette on board the steamer, quickly entered the
ring, Sayers attended by Jemmy Welsh and George
Crockett, Jones advised by Alec Keene and Mike
Madden. The stake was £100 a side. The career of
Tom’s youthful antagonist will be found sketched at
pages 253, 283, and 289 of this volume. Jones had
the advantage of Sayers in age by five years; his
height 5 feet 11½ inches, and his weight 12st.
Jones, after his defeat by Orme, was on the shelf
for a period of two years. He then came out with a
challenge to Tom Paddock, which was accepted, and
the men met July 18, 1854, at Long Reach, for £100
a side, and, after as gallant a struggle as was ever
witnessed, Jones became blind, and his friends gave
in for him, after fighting 121 rounds in two hours and
twenty-four minutes. So satisfied were his backers on
this occasion that they at once expressed their
willingness to make a fresh match. After some little
time articles were entered into, and they went into
training for the second mill. This affair came off at
Mildenhall on the 26th of June, 1855, and was
another display of manly courage and perseverance
on both sides. Towards the close Jones, who for
some time had the best of it, fell off very weak, and
Paddock, who, like his opponent, was much punished
and exhausted, saw that his time was come, and,
shaking himself together, he rattled away in style
until poor Aaron was once more compelled to cry “a
go,” after a contest of sixty-one rounds, in one hour
and twenty-nine minutes. Jones after this was
matched with the Tipton Slasher, as we have already
stated, but this went off; and this brings us to the
present meeting.
On entering the ring both men were loudly
cheered, and both looked equally confident. No
sooner had they put in an appearance than
speculation began. The Sayers party originally stood
out for 6 to 4, but being unable to get on at that
price, they reduced their demands to 5 to 4, at which
price considerable business was done, and a bet of
£10 to £8 was made and staked between the men. It
was piercingly cold; and, the ground being in a moist
state, all looked anxious for business, in the hope
that the excitement of the combat would dispel some
of the shivering fits to which the spectators, one and
all, notwithstanding their Crimean-looking outfits,
seemed to be subject. Little time was lost by the
men in denuding themselves of their remaining
outer-garments, and, the handkerchiefs having been
tied to the stakes (a light grey and white for Sayers,
and a neat white and blue check for Jones), at one
o’clock precisely “Time” was called, hands were
clasped, and the men began
THE FIGHT.
Round 1.—​On baring their forequarters to the piercing
breeze, a perceptible shiver ran through the carcases of the
combatants. Sayers looked in perfect condition; every muscle
was perceptible, and we doubt whether there was an ounce
of superfluous flesh about him. There was a smile of
confidence on his lips and bright sparkle in his eye that
betokened extraordinary health and spirits. His attitude was
artistic and firm, yet light. Of course he stood on the
defensive, and eyed his heavier opponent. There did not
appear to be that disparity of size that really existed; for
Jones stooped rather on throwing himself on guard, and thus
reduced his height almost to a level with that of the gallant
Tom, who was upright as a dart. Aaron’s condition did not
seem to us so first-rate as the first glance at him had led us
to suppose. His muscles, though large, were too well covered,
while his back and chest also displayed much superfluous
meat, and we should say that his weight could not have been
less than 12st. 4lbs. He, like Sayers, looked confident, but
was far more serious in his demeanour. They both
commenced the round with the utmost caution, sparring, and
attempting to draw one another into something like an
opening; but for a long time neither would throw a chance
away. At length Jones dashed out left and right; but the
blows passed over Tom’s shoulders, and Tom with quickness
tapped Aaron on the face, but without force. Sayers now let
go his left, but Jones retreated. Tom persevered, and was
cleverly stopped. In a third attempt, after more dodging, he
got heavily on Aaron’s mouth and stepped back without a
return. Jones now assumed the offensive, but was stopped,
and Tom, after another dodge or two, planted his left heavily
on the mark, and then the same hand on the side of Aaron’s
nut, but not heavily. Jones returned heavily on the right
peeper, and shortly after made a second call at the same
establishment. More stopping and dodging, until Sayers paid
another visit to Aaron’s kisser, Jones missing his return. Each
now stopped a lead; but immediately afterwards Jones
popped in his left on the snuff-box, a heavy hit without a
return. Tom grinned a ghastly grin; but the crack evidently
made him see stars. Jones attempted to repeat the dose; but
Tom got well away, and, as he retreated, popped his left on
the neck. More excellent stopping on both sides, and, after a
few harmless exchanges, Tom tried a double with his left and
got on the throat, but the blow lacked steam. Jones returned
with quickness over the left peeper, inflicting a cut and
drawing the claret. (“First blood” for Jones.) Tom, although
staggered, was undaunted, and went at his man with
determination. He once more got on the bread-basket heavily.
Good counter-hits followed, in which Jones again reached
Tom’s damaged peeper, drawing more of the essential, and
Tom delivered a straight one on the snout, removing a small
portion of the bark. Tom then got on the left eye, and, after
some sharp punching at close quarters, both fell. This round
lasted exactly half an hour.
2.—​Tom came up much flushed, and the crimson distilling
from his damaged eye. After a little dodging, he tried his
double, but did not get it home. He tried a second time, but
was stopped, and Jones returned on the left eye. This led to
very heavy counters, each on the larboard goggle. Jones now
feinted, and popped his left on the nose. They got hold of
one another, swung round, broke away, and Sayers then
popped his left again on the left eye. Severe exchanges
followed at close quarters, and both in the end were down.
3.—​Sayers quickly led off with his left, and was stopped.
He then tried his double, but was short. In a third essay he
got home on Aaron’s nose, but not heavily. Twice again did he
pop in gentle taps, but he now napped another rattler on the
left eye. Severe exchanges followed, Aaron again turning on
the stream from Tom’s left brow, and Tom tapping his
opponent’s snuff-box. More exchanges in favour of Jones; and
in the end both fell in a scrambling struggle, Jones under.
4.—​Tom’s left brow and the left side of his canister were
much swollen, but he was still confident, and led off, Jones
countering him well on the mouth. Heavy exchanges
followed, Tom on the nose, and Jones on the left cheek, and
both again slipped down, the ground being anything but level.
5.—​Tom let fly his left, but was neatly stopped; Jones
returned on the side of the brain pan, and got down.
6.—​Sayers came up, looking very serious, and it
subsequently turned out that he was suffering from severe
cramp in the stomach and lower extremities. He went in,
feinted, and got well home on Jones’s left eye. This led to
sharp exchanges and a close, when both were down, Jones
being underneath. Aaron had now a bump on his left peeper,
which was apparently closing.
7.—​Aaron lost no time in sending out his left, which fell on
Tom’s chest. Heavy counter-hits followed, Jones on the nose,
and Tom on the mouth. More exchanges in favour of Sayers,
who again got on Aaron’s damaged optic, and the latter got
down.
8.—​Sayers went to his man, and tried his double, the
second blow dropping on Aaron’s sneezer, and Tom then got
cleverly away from the return. Exchanges ensued, Tom on the
mark, and Aaron on the mazzard; Aaron then got home his
right heavily on the left side of Tom’s knowledge-box, then his
left on the left eye, and in the close Sayers was down.
9.—​Aaron led off, but was well stopped, and this led to
some sharp exchanges, Jones on the bad peeper, and Tom on
the left brow. Sayers tried another double, and once more
visited Aaron’s nose, but not heavily. More mutual stopping,
and Jones, at length, in getting away, slipped and fell. One
hour had now elapsed.
10.—​Tom planted his left on the beak, and received a little
one in return on the forehead. Jones now let fly his left and
right, but was cleverly stopped. In a second essay he got
home on the left cheek. Heavy exchanges followed, Tom
getting on both peepers, and Jones on the side of Tom’s
cranium with both daddles, and Tom fell.
11.—​Aaron had now a mark on each peeper, the left fast
closing. Tom’s left, too, appeared almost shut up. Jones tried
to take the lead, but missed; Sayers likewise missed his
return. Exchanges followed in favour of Jones, who, in the
end, closed, and in the struggle both fell, Jones uppermost.
12.—​No time lost; both quickly at it, and some sharp
exchanges took place in favour of Jones, who got heavily on
Tom’s nose. Tom made his left on the body heavily, and they
then pegged away wildly at close quarters until Jones got
down.
13.—​Aaron dashed in and pegged away left and right, but
without precision, and ultimately bored his man down.
14.—​Jones feinted and popped his left on the left eye,
without a return. Tom then let go his left, but was short, and
Jones, in dashing at him in return, slipped and fell.
15.—​Aaron led off, left and right, but Tom got away. He
came again, and tried to plant his left, but was short. He then
tried his double, but Jones got away. Both now sparred and
dodged, but nothing came of it. At last Jones dashed in, and
heavy exchanges took place in favour of Jones, who,
however, in the end, fell.
16.—​Both at once went to work, and heavy exchanges
took place, each napping it on the left ogle, and both fell
through the ropes.
17.—​Tom’s forehead and left eye much disfigured. Jones let
fly his left and right on the sides of the nob very heavily, and
both again fell through the ropes.
18.—​Tom came up slowly, and was nailed on the damaged
peeper. In return he caught Aaron on the brow, but not
heavily. Jones then made his left and right on the side of the
head and left eye, and Tom retaliated on the nose a little one.
A close followed, and in the end both were down, Jones
under.
19.—​Tom dodged and got home on Aaron’s smeller with his
left, and Aaron then made both hands on the left side of
Tom’s wig-block. A close and sharp struggle, when both fell,
Tom under.
20.—​Jones dashed in and let go both hands on the head.
Tom returned on the left brow, and both fell backwards.
21.—​Aaron again dashed in. He missed his right, closed,
and both fell, Jones under.
22.—​Tom now led off, but missed, and Jones caught him
heavily with his right on the frontispiece, and knocked him
down. (“First knock-down for Jones.”)
23.—​Tom, on coming up, showed the effect of the last
blow on his forehead. He attempted to lead off, but was very
short. He tried again with a like result; and Jones, in letting
go both hands in return, overreached himself and fell.
24.—​Aaron rattled in, planted his left and right on the
scent-box and left ear, the latter very heavy, and bored Tom
down.
25.—​Tom came up bleeding from a severe cut on the left
lug, and his gnomon much out of straight. He tried to lead
off, but Jones caught him on the right brow, but not very
heavily. Tom then got home on the body, and tremendous
counter-hits followed, in favour of Jones, who, in the end,
slipped and fell, Tom catching him, just as he reached the
ground, on the side of the head.
26.—​Jones went in left and right, closed, and both were
down. Sayers was now very weak, and the Jonesites were in
ecstasies.
27.—​Aaron led off, getting well on the side of Tom’s nut
with his right. Tom missed his return, and Jones then planted
his left and right on the top of the skull; closed at the ropes,
where Tom managed to throw him but not heavily.
28.—​Jones led off, and got well on Tom’s nose with his left,
and Tom returned on the side of the head. After a little
dodging, Jones popped his left on Tom’s left peeper, and his
right on the jaw, again flooring Tom and falling on him.
29.—​Tom, who was excessively weak, came up slow, but
determined; he tried his left at the body, but was short. Jones
then let fly his left in return, but was countered on the
mouth. He then planted his left and right on Tom’s damaged
listener, and in the end fell.
30.—​Aaron, after a few dodges, once more popped a little
’un on Tom’s ear. Tom thereupon dashed in, but got a little
one on the nose, and another on the side of the head, and
Jones, in getting away, fell, laughing.
31.—​Jones attempted to lead off, but Tom got away. Jones
followed him up, caught him again on the side of the nob,
closed, and both rolled over together.
32.—​Jones dashed in, planted both hands on the brain-
pan, closed, and forced Tom down.
33.—​Jones again rushed in, but inflicted no damage, and
again bored Tom down.
34.—​Jones still forced the fighting, and caught Tom, who
seemed very tired, on the side of the head, and, in the end,
both slipped down.
35.—​Sayers was forced down, after getting a gentle
reminder on the side of his damaged figure-head.
36.—​Tom, a little refreshed, sparred about for wind, until
Jones went in, and heavy exchanges took place, in favour of
Jones, when both fell backwards.
37.—​Tom, recovering a little, tried his double, but Jones
got away, and, as Tom came, he nailed him on the left brow.
Tom then made his left on the mark, but again napped it
heavily on the left eye. Aaron now got on the nose with his
left—​a heavy spank—​and, in getting back, he staggered and
fell.
38.—​Jones dodged, and planted his left on the mouth
heavily, and his right on the side of the head. Tom returned
slightly on the nose, and, after slight exchanges, both fell.
39.—​Very slight exchanges, and Sayers slipped down.
40.—​After a little sparring they got close, and exchanges
took place, each getting it on the mouth. Sayers then tried his
left at the mark, but Jones got away. Tom followed him up,
and was caught by Aaron, left and right, on the side of his
head and fell.
41.—​Tom came up, shook himself, and rattled in, but he
got it on the top of his cranium. Jones, in stepping back, fell.
Two hours had now expired.
42.—​Jones, steady, let go his left on the side of Tom’s
head, and then both mauleys on the same spot. Tom followed
him up, but got it again on the brow. He, however, got home
on Jones’s body, and, in retreating slipped and fell.
43.—​Long sparring for wind, until Jones once more made
play on the left side of Tom’s occiput, and then on his snout.
Tom returned on the latter organ, but not heavily. He now
tried his favourite double, but did not get home. In a second
attempt he got heavily on Aaron’s proboscis, and got away.
Exchanges followed, in which Tom again delivered heavily on
the nose with his left, and in the end Jones dropped.
44.—​Tom was now evidently recovering from his
exhaustion. He came up steadier, and sparred shiftily until
Jones commenced the attack, when he stopped him neatly.
Heavy counter-hits followed on the jaw, after which Sayers
tried the double once again, but was stopped. More good
counter-hits, Tom getting well on Aaron’s left eye, and
receiving on the mouth. Aaron’s left eye all but closed.
45.—​More sparring, until Jones let fly his left, but Sayers
got away. Exchanges followed, Tom on the whistler, and Jones
on the nose, but not heavily. More sharp counter-hitting, Tom
once more getting on the left eye severely. Jones returned,
but not effectively, with both hands on the side of the head,
and in getting away from the return he fell.
46.—​Jones succeeded in planting a spanking hit from the
left on the left eye, and then another with the same hand on
the left cheek. In a third attempt he was stopped. Heavy
counter-hits followed, and in the end Jones fell, Sayers falling
over him.
47.—​Aaron feinted with his left, and got well on Tom’s
nose; a very straight hit. Tom, in return, tried his double, but
was short. After some more ineffectual attempts they got to
it, and tremendous exchanges took place, each getting it on
the nose and left eye, and in the end Jones got down. Two
hours, fifteen minutes.
48.—​Tom tried to lead off, but was stopped, and Jones
planted his left on the cheek. Tom now stopped two of
Jones’s hits, after which heavy exchanges took place, Tom
getting well on to the left eye, and Jones on the nose. More
sharp exchanges, left and right, each getting pepper in
earnest, and the favours mutually divided. A break away, and
to it again, ding-dong, and Tom drew the crimson from
Aaron’s left peeper, which was now effectually closed. In the
end Jones fell. It was now anybody’s battle; Tom had quite
recovered his wind, and was nearly as strong as his heavier
opponent.
49.—​Both much punished. Sayers sparred until Jones tried
to lead off, when he got away. Jones followed him up, but
was short in his deliveries. In the end they closed, and as
they were falling Tom popped his right sharply on Aaron’s
back.
50.—​Jones, after sparring, led off, and got home on the
nose, but not heavily; Tom returned on the right peeper, and
some pretty exchanges, left and right, took place, followed by
a break away, and Jones then stopped Tom’s left; Tom, in
return, stopped Aaron, and planted his left on the mark, and
then on the left eye, and Jones got down.
51.—​Jones led off, but was stopped. He persevered, and a
good give-and-take rally followed, Jones getting on the left
eye, and Tom on the left cheek heavily. Tom next got on the
mouth, drawing the Burgundy, and then on the nose and left
cheek. Another sharp rally followed, after a break away, and
in the end both down.
52.—​Sayers visibly improving while Jones fell off. Jones
was short in his lead, and Tom returned on the smelling-
bottle, and got away. Jones followed and dashed out his left,
but Tom ducked his head. Tom then got home on the mouth
and nose, and drew more of the ruby from the latter
ornament. Jones succeeded in returning a little ’un on the left
eye, and Sayers slipped down.
53.—​Jones, who was bleeding from the left eye and
month, led off, but was well stopped. He then missed his left,
but in the end heavy exchanges, left and right, took place,
Jones on the side of the nut and the neck, and in getting back
he fell.
54.—​Tom now essayed a lead, but was stopped. A second
attempt reached Aaron’s body, but not heavily, and Jones
returned on the nose. Tom tried his double, but missed, and
Jones popped a little one on the mouth, and then his left on
the left eye, and fell in the corner.
55.—​Tom dodged about until he got within distance, and
then got home heavily on the mark. Jones returned on the
jaw with his right, but not heavily. After some more sparring,
Jones dashed in, when Tom met him very sharply on the right
cheek-bone with his left, and Aaron fell all of a heap. He was
carried to his corner, where it was with the utmost difficulty
he could be got round at the call of “Time.”
56.—​Jones came up all abroad, and Tom popped in
another spank on the same spot, whereupon Jones again fell.
It was thought to be all over; but, by dint of shaking him up,
Aaron was again enabled to respond to the call.
57.—​Tom rushed at his man to administer the coup de
grace, but, going in without precision, he contrived to run
against Aaron’s left, which was swung wildly out, the blow,
which alighted on Tom’s nose, regularly staggered him. He
quickly recovered himself, and went in again, but Jones fell
weak.
After this, the battle continued to the 62nd round, Jones
getting gradually blind, and Sayers becoming very tired. At
length in the 62nd round, after slight exchanges, the men,
who were much exhausted, stood still, looking at each other
for some time, their seconds covering them with rugs. Upon
this the referee and umpires called on them to go in and
finish. Both went to the scratch, but on Sayers approaching
Jones, the latter retreated to his corner, and Tom, in
obedience to the orders of his seconds, declined going to
fight him there. It was getting dark, and it was clear that
Jones and his friends were determined not to throw a chance
away. The referee once more called on Jones to go to the
scratch, which he did, but with precisely the same result; and
the referee, seeing that Tom was not strong enough to go
with prudence to finish on his adversary’s ground, and that
Jones was unwilling to try the question at the scratch in his
then exhausted state, ordered the men to shake hands,
leaving the motion as to further hostilities to a future day.
Both were severely punished; each had a peeper closed;
Jones’s right was fast following his left, and his right hand
was injured; so that a second meeting the same week was
not to be thought of. The fight lasted exactly three hours. The
men and their friends now hastened to regain the vessel, and
it was dark long ere the last of the company were safely on
board. Of course there were many laughable accidents in the
mud through which all had to wade; but luckily, nothing
occurred of a serious nature to mar the pleasures of the day,
which, although in some measure clouded by the fact that the
battle was not finished, still left sufficient impression on the
minds of the spectators to cause them to remember this
brilliant passage of arms, which formed so hopeful an
opening to the pugilistic year 1857. The vessel conveyed the
company with all due speed to a convenient place for
debarkation, whence they obtained a passage by railway to
the Metropolis, which was reached in safety by nine o’clock.
Numerous complaints were made by the disappointed ones
who went to the Great Northern Railway, at the manner in
which they were deceived; and the only consolation is that
we are sorry for those whom we should have been glad to
welcome at the ring-side, but who have themselves alone to
blame for not finding out the final fixture as many others had
done; while as to others of a certain class, who are always
more free than welcome, we can with truth say their room
was better than their company, and we rejoice, with others
who were present, that they were so completely sold. Some
unlucky wights got a sort of hint as to the fixture, and arrived
within a few miles of the spot at a late hour in the afternoon,
and were landed, but unluckily for them, on the wrong island,
and here the poor fellows had to remain all night, and sleep
under a haystack. The boats that landed them had departed,
and they could make no one hear; so that, cold, hungry, and
thirsty, they had to weather the cold, severe night in the best
way they could.

The renewed battle, which was for £200 and an


additional bet of £100, was fixed for Tuesday, the
10th February, 1857, on the same spot as the
previous gallant encounter. On this occasion Sayers
was seconded by Jemmy Massey and Bill Hayes, with
Jemmy Welsh as bottle-holder; Aaron Jones by Alec
Keene and Jack Hicks, Jack Macdonald taking care of
the restoratives. 7 to 4 on Sayers.
THE FIGHT.
Round 1.—​On toeing the scratch the condition of both men
struck the spectators with admiration. In our opinion it was
perfect on both sides, but the development of muscle was
decidedly in favour of Sayers, who is better ribbed up, and
has his thews and sinews laid on in the right place. He looked
brown, wiry, and healthy, and, for a middle weight, seemed
wonderfully big. Jones, who is of fairer complexion, was
altogether more delicate in appearance than Sayers, and,
although so much taller, heavier, and longer, did not loom out
so much larger as might be expected. He is a fine-made,
muscular young fellow, but still there is an appearance about
him which at once leads to the conclusion that his stamina is
scarcely fitted for the wear and tear of gladiatorial
encounters. He is about twenty-six years of age, and in height
is over 5 feet 11 inches, while Tom Sayers is thirty-one, and is
little more than 5 feet 8 inches. It was soon seen that Sayers
intended to pursue different tactics to those he adopted on
the previous occasion. He dodged about for a few seconds,
and then let go his left and right with great quickness, but
Jones stopped him neatly, and in getting back fell.
2.—​Tom came up smiling, feinted with his left, and then
tried his favourite double; the first hit was stopped, but the
second caught Aaron on the chin. This he repeated, and got
away without a return. After trying his double once more
without success, he planted his left very heavily on the mark.
Jones at once went to close quarters, and some quick in-
fighting took place in favour of Sayers, who got well on to
Aaron’s snuffbox with his left, drawing “first blood.” Jones got
on the left side of Tom’s head, but not heavily, and at length
both fell.
3.—​Both quick to the call of “Time,” and Sayers at once
went to work with his left, Jones countering him heavily, each
getting it on the forehead. Tom then popped his left on the
mark, and Aaron returned, but not heavily, on the nose. Tom
now again planted the left on the mark, and was stopped in a
second effort. Heavy exchanges next took place, Tom once
more drawing the cork from a cut on Aaron’s sniffer, and
receiving on the left ear. After a few dodges, Tom again
approached, and made a heavy call on Aaron’s bread-basket,
then planted a stinger between the eyes, and got away
laughing. He attempted to repeat the dose, but was stopped.
Another effort was more successful, and he dropped on the
mark, staggering Jones, who, however, recovered himself,
and popped his left on the chest, then on the left cheek, but
not heavily. Sparring until Tom got within distance and shot
out his left heavily on the proboscis, without a return, Jones
being a little wild. Tom now essayed his double, but Jones got
away, and returned on the mouth. Tom persevered, and
napped a little ’un on the left eye for his pains; still, he would
be at work, and got well on Aaron’s left peeper, drawing the
ruby. Heavy exchanges followed, Jones getting on Tom’s left
brow, and Tom turning on the home-brewed from Aaron’s
nasal organ. After two or three slight exchanges in favour of
Sayers, he again put the double on, reaching the left cheek
and bread-basket. Next he popped another hot one on the
victualling department, receiving a slight return on the
forehead. After a break away he stole in, and bang went his
left on Aaron’s damaged eye, drawing more of the ruby. A
merry little rally followed in favour of Sayers, who at last
broke away, and sparred as if blown from his fast fighting.
Jones approached to take advantage of this, when Tom
propped him on the brow, and then on the forehead. Jones
returned with both hands, but not heavily, on the brow and
body, and another bustling rally came off, Tom getting home
on the left ogle and throat heavily, and Aaron on the larboard
cheek. Another break away, and Tom, on getting himself
together, resumed the double, got on the mark very heavily,
and then popped his right on the left side of Aaron’s nob; he
got away laughing, and as Jones tried to follow him up he
warned him off by a pop on the left eye. A heavy rally at last
took place, in which Jones got sharply on the left ear, and
Sayers on the left eye, and this protracted and well-fought
round was concluded by Tom slipping down.
4.—​Sayers, on coming up, showed a mark on his forehead,
and another on his left ear, while Aaron’s left eye and nose
were much out of the perpendicular. Tom lost no time in
going to work, and planted his one, two, the left on Aaron’s
right eye, and the right on the left jaw, knocking Aaron off his
pins. (“First knock-down” for Sayers.) Jones seemed all
abroad, and it was with the greatest difficulty that he was got
round to the call of “Time.”

You might also like