• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Testing - Max's Book

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bump.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bump again
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic