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
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

How to catch thread number of an application

Hello guys'

 

My application uses many threads. I need to catch current threads number when starts new thread.

Sometimes my application stopped by unkown catch exception then terminated.

 

Tnx guys'

 

 

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to catch thread number of an application

Will Thread.activeCount() help you?

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to catch thread number of an application

Thank you man' cool'

 

Happy Valentine's day' :smileyhappy:

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: How to catch thread number of an application

Usually the default toString() on complex objects gives something like a hex identifier which

could help in disambiguating instances. You can count instances of your own classes if that helps

and sometimes this is desirable.

 

static volatile int born, buried;

int m_serial;

// illustration only, could just use one but I'm making a point LOL

private static Object lock1= new Object(), lock2=lock1; // new Object();

// all the ctors need to call this to get their serial number

private static int birth()  { synchtonized (lock1) {return ++born; } }

// call from finally block in run, isn't sufficient for thread death but necessary

// based only on this usage, lock1!=lock2 is fine and if you didn't want to hold up births while counting the

// dead, these can be different.

private static void death() { synchronized (lock2) { ++buried; }}

 

 

 

 

 

Please use plain text.