This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes Thread doesnt go down even when node or instance is shut down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Thread doesnt go down even when node or instance is shut down" Watch "Thread doesnt go down even when node or instance is shut down" New topic
Author

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

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Dec 05, 2008
Posts: 207
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Dec 05, 2008
Posts: 207
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread doesnt go down even when node or instance is shut down
 
Similar Threads
WSAD 5.1.1 - "EAR Validation failed"
JCA / J2C 1.5 Connector in Websphere 6.0
Remove Enterprise Application
Class-Path reference is not working on EAR file.
AspectWerkz with Websphere