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
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800

Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

Hi ,

 

     I am developing database based project. Here Three tab buttons are there. each button represent each screen.

when i am navigating from one screen to another screen using tab button,then automatically one thread created.

but i am not using any threads here. in this process means when ever i click ant tab it create one new thread with same name.

 

each screen starting i am monitiring thread name and number using

"  System.out.println(Thread.currentThread().getName()+"======================="+Thread.activeCount());"

 

here i ubserve that thread name is same but number of threads increasing.

 

when the number reach 64, after the project Freezing( Too many threads error). at the time i need to reboot the mobile.

 

here i want to now that how to kill the active background threads?

 

-----------please help me, i am strucking here

Please use plain text.
Developer
ankit
Posts: 146
Registered: ‎07-24-2008
My Device: none

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

Hi Govind
can you post some code here.
What exactly your threads are doing.

Thanks
Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

[ Edited ]

I hope I am understanding you correctly. I think you want a way to get a list of all the background threads for a process and a method to kill them. I don't know of any way to do that so I am going to present a way that involves keeping track of all the threads your application creates, then call a kill command on them.

To kill a thread I believe all that needs to occur is for the run() method of the thread/runnable argument to complete. You could pass a kill switch that brings the thread/runnable to the end of its execution. Keep track of all the active threads/runnables you create then just kill them when you need to.

 

Psuedo code:

 

Runnable runnable1 = new Runnable() 
{
    private boolean killActivated=false;
    public void run() {
        while (kill()==false) {
            // do stuff
        }
    }
    private boolean kill() {
        return killActivated;
    }
    public void setKill() {
        killActivated=true;
    }
}

When it is time to kill the thread, call "runnable1.setKill();".  Keep track of all of the threads/runnables your application creates in an array or whatever manner you choose.


Scott

Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

thank u for ur replay dear

 

Runnable runnable1 = new Runnable()
        {
            private boolean killActivated=false;
            public void run() {
                while (kill()==false) {
                    // do stuff
                }
            }
            private boolean kill() {
                return killActivated;
            }
            public void setKill() {
                killActivated=true;
            }
        };

 

you r giving this code but here how i invoke setkill() method by using runnable1 object

 

plz help me

Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

I  want a way to get a list of all the background threads for a process and a method to kill them.

Please use plain text.
Developer
ankit
Posts: 146
Registered: ‎07-24-2008
My Device: none

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

HI

As such there is no facility available to get the threads and also you have to implement your own logic to close a thread.

 

Ankit

Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Please use plain text.
Developer
jitendrasharma
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

please use Thread.activeCount(), its gives exact no of threads running at the time.

Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

thank u dear,

could  u plz tell me, when i am goining to one screen to another screen ,automatically thread created.

y it is created?

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

"goining to one screen to another screen ,automatically thread created.y it is created?"

 

If you use pushModal, this will use a Thread.  Try not to use pushModal.

 

Also can I ask you to please spell check and use proper English on these posts.  Remember that some of our readers do not use English as their first language and will not understand abbreviations and spelling mistakes.  Thanks

Please use plain text.
Developer
jitendrasharma
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Please help me how to solve the when the Threads count reach 64, after the project Freezing( Too many threads error).in blackberry?

If your problem has been solved, please mark problem as solved, and post new query in another thread.

Please use plain text.