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
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500

Thread not running continously

I made a simple application in which I am running multiple threads. But mostly some thread get stuck means they do not execute. Can anyone suggest what could be solution for this.

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Thread not running continuously

I am not aware of the OS stopping Threads that are working.

 

So I guess the reason they stop, is something in the application or the environment.  For example, if the device goes to sleep, then any background Thread that does networking will probably fail.  The best thing I think you can do is put logging into your Threads, make sure you have appropriate try/catch clauses and then review the log when the unexpected happens. 

Developer
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500

Re: Thread not running continuously

Yes thread are doing network operation. Calling web service. but others threads working fine. What could be the reason only one thread stops.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Thread not running continuously

The network operation was just an example,  Another example is accessing persistent store, which might fail when the device is locked.  It all depends on what your Thread does.   

 

For the Thread to stop, it seems most likely that there was a failure in the processing.  So what was that failure?  I suggest you put appropriate logging and try/catch code and find out! 

 

Please don't post your code and ask us to debug it. 

Developer
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500

Re: Thread not running continuously

There is no problem in code. Thread are running fine when i test application in simulator. Its stop when test on device.??

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Thread not running continuously

[ Edited ]

"There is no problem in code."

 

Are you sure?  If there was no problem in the code, why does it stop?

 

As noted, you have some Threads that carry on, and this one Thread that stops.  There is nothing in the OS that will automatically stop Threads.  So it seems the most logical conclusion that can be drawn is that there is something in your code that results in it stopping.  Can you give any other explanation?

 

"Thread are running fine when i test application in simulator"

 

Next time give us this sort of information right up front.  It would have been useful to know it was a networking Thread too.  The more information you give us, the more specific our answers will be.  See this Thread which is a sticky Thread right at the top of the list....:

http://supportforums.blackberry.com/t5/Java-Development/Information-to-include-when-posting-to-the-J...

 

As you should be aware, a Simulator and the device are not the same thing.  The differences that normally catch people out are:

1) there are normally no Application Permissions required on the Simulator.

2) network processing is very quick, which means that using the Simulator you can get away with doing network processing on the Event Thread.

3) Network processing doesn't suffer from the problems caused by wireless connections, like connection limits or transcoders changing your wireless communications. 

4) Long running processing can run on the Event Thread because the PC is so fast.

5) Different levels of OS on Simulator and device cause subtle differences in the processing, for example the order in which asynchronous events happen.

These are only the most common examples, there are other differences.

 

With the information we have, we can't even guess what the problem is. 

 

I think the following comment from my first post still applies.

"The best thing I think you can do is put logging into your Threads, make sure you have appropriate try/catch clauses and then review the log when the unexpected happens."