This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

a question on multithreading

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers .

If i am having 5 threads in a program and 2 are dameon threads and rest 3 are user threads , if either one of them throw a unhandled exception let it be user thread , will all of my threads will stop running or that particular thread will stop running allowing other threads run safely.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
the answer to your question is that it won't affect the other thread and only the current thread will throw the exception and since the exception is not handeled it will terminate. hope this solves yours doubt
rohit suman
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output (actually, a snapshot of it):

In main, i is 16
In main, i is 17
In main, i is 18
In main, i is 19
In main, i is 0
In main, i is 1
In main, i is 2
In main, i is 3
In main, i is 4
i is 5, i/i is 1
i is 4, i/i is 1
i is 3, i/i is 1
i is 2, i/i is 1
i is 1, i/i is 1
Exception in thread "Thread-0" java.lang.ArithmeticException: / by zero
at Job.run(ThreadDemo1.java:7)
at java.lang.Thread.run(Unknown Source)
In main, i is 5
In main, i is 6
In main, i is 7
In main, i is 8
In main, i is 9
In main, i is 10
In main, i is 11
In main, i is 12
In main, i is 13

Does that answer your question?
[ September 12, 2006: Message edited by: Aniket Patil ]
 
Ajit Amitav Das
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Aniket for a fine example .i got cleared my doubt.
 
my overalls have superpowers - they repel people who think fashion is important. 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