• 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

Another question from javacross simulation!

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
here is a question from http://www.javacross.com simulation please help me for a solution.
Q].You are updating some data and is result of some calculations. When your thread performs an integer division by 0 causing an ArithmeticException, you have no catch code, which of these will happen
a].the application will terminate
b].the JVM will start a new thread to perform the update operation
c].the application will not terminate but the updating will cease
d].none of the above will happen
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the application will terminate and a stack trace will be printed on the screen.
------------------
SeE Consulting(P) Ltd
Bangalore,India
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree, anuragiri
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your application may or may not terminate. Whenever there is an uncaught exception in a thread, that thread dies. Ofcourse if your program has only 1 non-daemon thread, i.e. user-thread (for eg. only a main thread), then JVM will exit. Otherwise if there are multiple daemon threads running, then the other threads will happily continue to run and JVM will not exit.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree with u Junaid
Noel try this code and u will get the answer
public class A extends Thread{
static int i=0;
public void run()
{
System.out.println("all done before"+i);
if (i ==0)
i = 1/i;
System.out.println("all done"+i);
}
public static void main(String[] args){
A t1 = new A();
t1.start();
try{
sleep(200);}catch (Exception e){}
i++;
A t2 = new A();
t2.start();
System.out.println("all done. exiting now");
}
}

HTH
anil
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at 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