BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 03-22-2009, 04:59 AM   #1 (permalink)
New Member
 
Join Date: Sep 2008
Model: 8100
PIN: N/A
Carrier: AT&T
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Thumbs Must Hurt
 
Join Date: Nov 2008
Location: Sioux Falls, SD
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 65
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: AT&T
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (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

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


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

For Siemens SIMATIC S7-200 CN 6ES7 291-8GE20-0XA0 6ES72918BA200XA0 PLC
$17.0
For Siemens SIMATIC S7-200 CN 6ES7 291-8GE20-0XA0 6ES72918BA200XA0 PLC pictureSIEMENS 52SW2BDB Selector Switch
$47.0
SIEMENS 52SW2BDB Selector Switch pictureSiemens 1P Standard Circuit Breaker 40A 120/277VAC, ED41B040
$192.95
Siemens 1P Standard Circuit Breaker 40A 120/277VAC, ED41B040 pictureSIEMENS Kammrelais V23054-E1020-F110 Cradle Relay 24V DC
$25.0
SIEMENS Kammrelais V23054-E1020-F110 Cradle Relay 24V DC picture1pc Used Good Siemens 6ES7642-5EG10-0XX0 by DHL EMS
$2399.0
1pc Used Good Siemens 6ES7642-5EG10-0XX0 by DHL EMS picture






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