BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-14-2007, 02:12 PM   #1 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Thread.join hanging processor

Please Login to Remove!

In certain cases, I'm attempting to suspend or destroy a data processing thread that lives in the background. When I run [threadName].interrupt() where threadname is a static member in another class of type thread, it seems to have no effect. If I run [threadName].join(), it pins the emulator cpu usage at 100% or so, and on a device it exhibits some strange behavior. Any suggestions all?
Offline  
Old 03-15-2007, 12:41 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

[threadName].join() doesn't suspend or destroy thread [threadName]. It suspends current thread until [threadName] is finished.
Offline  
Old 03-15-2007, 11:42 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Right, looks like it says that right there in the api, oops.
Is there any way to outright destroy a thread short of letting the thread.run method end gracefully?
Offline  
Old 03-15-2007, 11:42 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Right, looks like it says that right there in the api, oops.
Is there any way to outright destroy a thread short of letting the thread.run method end gracefully?
Offline  
Old 03-15-2007, 12:02 PM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is no way to kill (stop) the thread, which is blocked by IO operation
Offline  
Old 03-15-2007, 12:04 PM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, thanks for the heads up
Offline  
Old 03-16-2007, 06:07 AM   #7 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can try a while/do block around the things in the run method, depending on a (static) boolean. If you change the boolean from your main thread the condition for the do/while is no longer true so it stops.
Not sure if this interrupts an i/o operation waiting for timeout but in general you can kill a process like this.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 03-16-2007, 06:32 AM   #8 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it will not solve the problem with the blocking call (IO, for example).
otherwise - I agree with Simon: it is the only working workaround which I know.

minor correction - I usually extend Thread class and define stop flag variable (non-static) there. It allows to control different threads separately from each other.
Offline  
Old 03-16-2007, 09:39 AM   #9 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's what I've wound up doing, maybe not as graceful as an outright destroy but it does the trick.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.