×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    1

    Class used by multiple MIDlets in a MIDlet suite

    As an example of the sharing of classes and data between MIDlets, suppose a MIDlet suite contains a class called Counter, intended to keep count of the number of instances of MIDlets from that suite are running at any given time.

    public class Counter {
    private static int instances;

    public static synchronized void increment( ) {
    instances++;
    }

    public static synchronized void decrement( ) {
    instances--;
    }

    public static int getInstances( ) {
    return instances;
    }
    }

    Only a single instance of this class will be loaded in the Java VM, no matter how many MIDlets from the suite that supplies it are running in that VM. This means that the same static variable instances is used by all of these MIDlets, and, therefore the increment and decrement methods all affect the same counter. The fact that these methods are synchronized protects the instances variable from concurrent access by any threads in all of the MIDlets.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Class used by multiple MIDlets in a MIDlet suite

    Moved this post to a new thread as I did not see this in any way connected to the previous thread.

    Is there a question in here, or was this an answer to a question in some other thread?

    Hartti

Similar Threads

  1. calling midlet from midlet throws SecurityException on 6600
    By brianpegan in forum Mobile Java General
    Replies: 3
    Last Post: 2010-10-25, 05:31
  2. Linking Error(Undefined Symbol)
    By nile_mail in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 10
    Last Post: 2008-03-26, 23:32
  3. send array[0] different class
    By gift_te in forum Symbian
    Replies: 0
    Last Post: 2007-03-28, 13:04
  4. Accessing RMS of a different Midlet Suite
    By brianpegan in forum Mobile Java General
    Replies: 1
    Last Post: 2003-12-10, 16:11
  5. loading ressources using nokia midlet suite
    By b_varasse in forum Mobile Java General
    Replies: 0
    Last Post: 2002-05-16, 11:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×