Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing - Max's Book

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
In your book, there is a test package. I don't quite understand some code in DBTestRunner.java, that is,
while (test1.isAlive()
&& test2.isAlive()
&& test3.isAlive()
&& test4.isAlive()
&& test5.isAlive()
&& test1.isAlive()) {
}
System.out.println("Completed all tests.");
This means that if one thread is dead, then the test is completed. Why?
As I imagine, if the test is completed, then all thread should be dead. Can you explain?
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Mike,
I don't have the book handy. Can you give me a little more context?
M
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
The following is the full code:

[Andrew: I have put the code in between a UBB [code] and [/code] tags. This ensures that indenting is preserved, and makes the code easier to read. If you edit this post, you will see what I have done.]
[ September 16, 2003: Message edited by: Andrew Monkhouse ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point, this seems to be a bug. I'd suggest replacing the while loop with:
test1.join();
test2.join();
test3.join();
test4.join();
test5.join();
test6.join();
This could at least be done in the downloadable verion of the code, right? The code is also listed on p. 333; guess that need to be in the errata.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11905
207
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic