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
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
Accepted Solution

Java thread question

I have an ever running task (listener) that starts various threads.

 

class Combo extends Application implements GlobalEventListener

 {

  public static void main(String[] args)
   {

     .

     .

   private void something()

     {

        PlaceCall PC = new PlaceCall(PBXNumber,3000);

        New Thread(PC).start();

 

 

 

public class PlaceCall implements Runnable
{
    String Number="";
          
    public PlaceCall(String phoneNumber,int wait_time)
    {   
      Number = phoneNumber.trim();

     .

     .
    }
  public void run()
  {

 .

 .

 

private void "something"  is executed often. Is "PC" completely removed from memory after its thread has finished?

 

If not how should I change the code?  PC is also called from other routines with other parameters. and I have many similar threads doing other things

 

The code works as coded, I use it in several other instances but I am worried about memory leaks.

 

 

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Java thread question

PC should be removed unless it has a reference to another object (or a member) which keeping it alive.

 

Use the profiler and you can see if the objects are cleaned-up or not.

 

E.

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Java thread question

profiler

 

Have to read up on that.  Does it work in simulator?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Java thread question