BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-22-2009, 04:59 AM   #1
bhushan.kasturiwale
New Member
 
Join Date: Sep 2008
Model: 8100
PIN: N/A
Carrier: AT&T
Posts: 9
Default Too many Threads Uncaught Exception

Please Login to Remove!

Hi ,
We are having an application in which we are frequently getting the uncaught exception of TooManyThreadsException.
Can any one tell how many maximum threads are supported in a Blackberry Device.
Or how can we fix this issue ?
Offline  
Old 03-22-2009, 01:06 PM   #2
zechariahs
Thumbs Must Hurt
 
Join Date: Nov 2008
Location: Sioux Falls, SD
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 65
Default

A simple Google search reveals:

BTW - The answer is 16.
__________________
Handspring >> Palm >> BB Pearl >> BB Storm

Tumblog: http://www.geekkink.com
Blog: http://www.zechariahs.org/blog
Offline  
Old 03-23-2009, 12:04 AM   #3
WonderfulRemote
Knows Where the Search Button Is
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: AT&T
Posts: 16
Default

Rather than spinning off threads for each and every task its recommended that you implement the work queue pattern. Its quite a simple idea, where you spin up a thread which sits around waiting on a semaphore to be posted to. Once the sema gets a post the thread goes and pulls an item out of the top of a vector and invokes execute() on it.
You can obviously implement this with a pool of worker threads waiting on the semaphore.
In your application code rather than creating new threads, you simply construct new WorkItem objects that implement the work item interface:
Code:
interface WorkItem {
void execute();
}
And add them to your work queue. The add method for your work queue should add the item to the Vector and post to the semaphore (releasing a thread to work on this item if its free). This isn't terribly different to spinning up a new thread from a coding perspective your just switching out 'extends Thread' with 'implements WorkItem' and renaming run as execute. This is of course once you've implemented the work queue classes/infrastructure.
Offline  
Old 03-23-2009, 04:07 AM   #4
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

don't forget to synchronize the vector access, the j2me vector class is not synchronized per se.
work queues are indeed a good solution, you can also use a thread factory.
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts picture

4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts

$49.99



Ballast Box 3 Pt Hitch 800LBS Counterweight for Cat 1 Tractor Steel Heavy Duty picture

Ballast Box 3 Pt Hitch 800LBS Counterweight for Cat 1 Tractor Steel Heavy Duty

$193.99



Accupro 703-00004-001  1 or 2 lamp T12 Rapid-Start Electronic Ballast  picture

Accupro 703-00004-001 1 or 2 lamp T12 Rapid-Start Electronic Ballast

$8.50



Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12 picture

Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12

$18.79



Universal Lighting M175MLTAC3M-500K Metal Halide Magnetic Ballast Kit CWA picture

Universal Lighting M175MLTAC3M-500K Metal Halide Magnetic Ballast Kit CWA

$12.00



Fulham Pony Solid State electronic ballast picture

Fulham Pony Solid State electronic ballast

$15.00







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