• 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

Thread doesnt go down even when node or instance is shut down

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

we are facing a problem and i want to know if this is a bug in websphere?
we have deployed an EAR on websphere. The EAR has a thread which has an infinite loop.
The thread starts when instance is made up. But the thread does not terminates when the instance is made down from the browser UI. The thread keeps on running in memory till the websphere is restarted completely from the command line.

Can someone please tell me if this is a bug or I am expecting something which I should not expect.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I'm assuming this thread is being spawned from code that you wrote. In which case presumably you can tell whether there is also code which is designed to cause it to terminate... so is there? There's no reason to expect it to terminate unless there is a process in place to cause that to happen.
 
Yogesh Gandhi
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes the thread is being spawned from the main Thread ( if i understand the meaning of spawned correctly )

But getting the main thread down will not automatically let the child threads down?

I have not written any special code to terminate the thread.

Well if you have any idea how can i write such a code..can you please help me with a dummy example?

i have a main thread that creates instance of another thread and starts it.
Any clue how can i terminate it when instance is made down?
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yogesh Gandhi wrote:But getting the main thread down will not automatically let the child threads down?



No, why would it? (By the way your term "child thread" doesn't correspond to anything in the Java runtime, it's just how you think of the threads. There isn't any way for a thread to determine which thread created it.)

I have not written any special code to terminate the thread.



And so that's why it doesn't terminate. (Your mental picture of a tree structure of threads with parents and children, where the children must stop if the parent stops, doesn't correspond to reality.)

Well if you have any idea how can i write such a code..can you please help me with a dummy example?



The usual way is for the master thread to interrupt the slave thread, and for the slave thread to be written in such a way that when it is interrupted it terminates. Quite often this is arranged by the slave thread to have a boolean variable, which it checks periodically, and when something (i.e. the master thread) sets that variable to true (let's say) then the slave thread terminates when it notices that.
 
Yogesh Gandhi
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the boolean variable is there is our slave thread.
we have a while loop based on this variable's value.

But what my brain is not able to accept it is when the whole instance is down or even i make my node down in websphere, even then the thread is executing. Doesn't that looks weird? Usually end user will think that if i stop my instance, everything related to that instance will go down.

But he was surprised to see that something is pumping data into tables even when the instance was down...

can someone please tell what happens technically when we make a node down? does it takes a process down? killing a process doesnt kill threads under it?


some more thoughts into this please.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yogesh Gandhi wrote:But what my brain is not able to accept it is when the whole instance is down or even i make my node down in websphere, even then the thread is executing. Doesn't that looks weird? Usually end user will think that if i stop my instance, everything related to that instance will go down.



Then it looks like you're making another unwarranted assumption. Let me point out that the word "related" in that sentence is another non-technical word which is probably hiding that assumption. So, yes, I agree that you need to look at the technical aspects of what's happening in a more critical way.
 
reply
    Bookmark Topic Watch Topic
  • New Topic