Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified
Accepted Solution

Too many threads error

Hi
I am developing an application for BlackBerry with around 20 -25 MainScreens after navigating through the screens for some time the application crashes with too many threads exception. I am using invokeLater to push each screen
any way to resolve this issue ??

Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Too many threads error

Without actually seeing your code it will be hard to point you to where it may be going wrong. But 20 to 25 screens sounds already a lot. Are you pushing them all one after the other? I think a stack of more than 10 screens should alarm you.

 

Also you don't always have to use invokeLater to push a screen. You only have to use that if you want to push a screen from a non UI thread. 

Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: Too many threads error

My application is a having 23 different screens and based on the states different screens need to be pushed.
The overall architecture is as follows

MainScreen screen;
screen = mainScreen1();
screen = mainScreen2();
screen = mainScreen3();
............
screen = mainScreen20();

invokeLater(){
pushScreen(screen);
}

This is how we had implemented. Do u have any suggestion for this implementation.

Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Too many threads error

I am not quite sure yet if I really follow your thoughts but why would you initialise 23 screens all at once and then push only one?

 

The code below doesn't make any sense as it stands there. Why would you assign the return value of mainScreen1() to the local variable of screen and then the mainScreen2() overwrites it straight after?

 

 

Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: Too many threads error

All the 23 screns are not initialized in one shot

its actually as follows

static MainScreen screen;-global variable 

 

 

swtich (main_State){

case 1:screen = new MainScreen1();

             break;

case 2: screen = new MainScreen2()

.....

 

invokeLater(){

pushScreen(screen);

}

Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Too many threads error

And when  you state changes and you push a new screen, do you ever pop previous screens from the stack or do you just keep pushing screens?

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Too many threads error

Where are all the threads coming from?




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: Too many threads error

I am not  popping the previous screen for the back key functionality.

Popping will solve this problem ??

Then the back key functionality i need to implement some other way

Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: Too many threads error

I assume invokeLater will create seperate threads I dont know exactly.  

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Too many threads error

invokeLater() does not create a thread.

 

It queues up a Runnable object to be executed in the event thread.

 

 

Please use plain text.