• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Runtime Errors

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, whilst studying for the SCJP, I would like to ask is there a specific list of Runtime errors?
For example:
A)Restarting a dead thread
B)Attempt to access an array element outside the size of the array?
Thank you
Tony
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A) You can not restart a dead thread
B) You get an ArrayIndexOutOfBoundsException when you attempt to access an array element outside the size of the array.
Cheers!


Hi all, whilst studying for the SCJP, I would like to ask is there a specific list of Runtime errors?
For example:
A) Restarting a dead thread
B) Attempt to access an array element outside the size of the array?
Thank you
Tony


[ February 03, 2003: Message edited by: Roan Nicolas ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code shows that once a thread has died, there is no way to restart it.

The string "running..." is only output once which clearly shows that the thread has only been started once.
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are we not getting IllegalThreadStateException when we are calling the start method second time on this thread?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thread has died. join() means "Waits for this thread to die"
So you won't get the mentioned Exception unless you change your code as follows:-
public static void main (String [] args) throws Exception {
Test t = new Test();

t.start();// start the thread
t.start();// start it again
t.join();// wait for it to die
}
[ February 04, 2003: Message edited by: Michelle Joe ]
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can find more here:
Join method on thread
 
You don't like waffles? Well, do you like this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic