Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Testing - Max's Book

 
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?
 
town drunk
( and author)
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 ]
 
Wanderer
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump again
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic