Skip to Main Content
Java
book

Java

by Michael Sikora
January 2003
Beginner to intermediate content levelBeginner to intermediate
150 pages
7h 28m
English
Morgan Kaufmann
Content preview from Java
! 58
Chapter 10: Threads
II
10.2 Multithreaded Application Example
To illustrate what we have covered so far, we introduce a Java application,
PrintNumbersThread,
which includes thread code that simply lists the numbers 1 to i0. The application will have
two thread instances; the thread will append the thread instance name to the output number
so that we can distinguish between the instances. Finally, we will use the sleep method within
the thread's run method to cease execution every half-second so that we can interleave the two
thread instances' output.
PrintNumbersThread
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class PrintNumbersThread ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JAVA Programming

JAVA Programming

K. Rajkumar
Java Programming

Java Programming

Hari Mohan Pandey
Java Programming

Java Programming

Poornachandra Sarang
Java 9 for Programmers

Java 9 for Programmers

Paul J. Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781558609099