To ragnic and other about Singleton class

Hi ragnic. Thanks for your reply. I posted the code wrong. Heres' my correct one.
I have a GUI first loaded information and the information is stored in a databse, I have some EJB classes..and my singleton class ABC has some method to access to the EJB..
so my first GUI will gather info using singleton class and later if I click on
a button in my first GUI class, will pop up another frame of another class , this class also need to class setPassword in my Singleton..
are my followign codes correctly??
iS my Class ABC a SINgleton class? thanks
Is my class ABC use as single correctly. And It is called from other classes is also correct?
I'm new to java and like to learn about Singleton class.
But I really dont' understand it clearly after reading many examples of it.
I have a project to convert my class abc to a singleton.
But I dont know how to do it.
In my class(soon will become a singleton) will have few methods that later I need to use it from another class A and class B.
I have a GUI application that first load my class A..and my class will call
class abc(singleton) to get some information from it.
and then in class A has a button, if I click on that button I will call SIngleton class again to update my password, in the singleton class has method calls updatePassword. But I dont know how to call a singleton from other class.
I have my code for them below:
1)public class ABC //attempt using a singleton
private static ABC theABC = null;
private ABC(){}
public synchronized static ABC getABC()
if(theABC == null)
theABC= new ABC();
return the ABC;
public void updateUserInfo(SimpleUser user)
throws UserNotFoundException, DelegateException
try
UserCollectionHome userCollectionHome = (UserCollectionHome)
EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
UserCollectionHome.class);
UserHome userHome = (UserHome)
EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
UserCollection uc = userCollectionHome.create();
uc.updateUserInfo(user, userHome);
} catch(HomeFactoryException hfe) {
hfe.printStackTrace();
throw new DelegateException(hfe);
} catch(RemoteException re) {
re.printStackTrace();
throw new DelegateException(re);
} catch(CreateException ce) {
ce.printStackTrace();
throw new DelegateException(ce);
} catch(FinderException fe) {
fe.printStackTrace();
throw new UserNotFoundException();
public SimpleUser getID(String id)
throws UserNotFoundException, DelegateException
try
UserCollectionHome userCollectionHome = (UserCollectionHome)
EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
UserCollectionHome.class);
UserHome userHome = (UserHome)
EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
UserCollection uc = userCollectionHome.create();
SimpleUser su = uc.getID(id, userHome);
return su;
} catch(HomeFactoryException hfe) {
throw new DelegateException(hfe);
} catch(RemoteException re) {
throw new DelegateException(re);
} catch(CreateException ce) {
throw new DelegateException(ce);
} catch(FinderException fe) {
throw new UserNotFoundException();
public void setPassword(String lname,String pw)
throws UserNotFoundException, DelegateException
try
UserCollectionHome userCollectionHome = (UserCollectionHome)
EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
UserCollectionHome.class);
UserHome userHome = (UserHome)
EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
UserCollection uc = userCollectionHome.create();
uc.setPassword(lname,pw, userHome);//assume that all lname are differents.
} catch(HomeFactoryException hfe) {
hfe.printStackTrace();
throw new DelegateException(hfe);
} catch(RemoteException re) {
re.printStackTrace();
throw new DelegateException(re);
} catch(CreateException ce) {
ce.printStackTrace();
throw new DelegateException(ce);
} catch(FinderException fe) {
fe.printStackTrace();
throw new UserNotFoundException();
}//Do I have my class as a Singleton correctly???
2)//Here is my First Frame that will call a Singleton to gather user information
public A(Frame owner)
super(owner, "User Personal Information",true);
initScreen();
loadPersonalInfo();
* This method instantiates all the GUI widgets and places them into panels and
* onto the frame.
private void initScreen()
txtFname = new JTextField(20);
txtLname=new JTextField(20);
btnsave =new JButton("Save");
btnChange= new JButton("Click here to change PW");//when you click this button there will be a frame pop up for you to enter informaton..this iwll call class B
JPanel pnlMain=new JPanel();
JPanel pnlFname= new JPanel();
pnlFname.setLayout(new BoxLayout(pnlFname, BoxLayout.X_AXIS));
pnlFname.setBorder(BorderFactory.createEmptyBorder(0,87,0,90));
pnlFname.add(new JLabel("First Name:"));
pnlFname.add(Box.createRigidArea(new Dimension(5,0)));
pnlFname.add(txtFname);
JPanel pnlLname= new JPanel();
pnlLname.setLayout(new BoxLayout(pnlLname, BoxLayout.X_AXIS));
pnlLname.setBorder(BorderFactory.createEmptyBorder(0,87,0,90));
pnlLname.add(new JLabel("Last Name:"));
pnlLname.add(Box.createRigidArea(new Dimension(5,0)));
pnlLname.add(txtLname);
pnlMain.add(pnlFname);
pnlMain.add(pnlLname);
pnlMain.add(btnsave);
pnlMain.add(btnChange");
btnSave = new JButton("Save");
btnSave.setActionCommand("SAVE");
btnSave.addActionListener(this);
btnCancel = new JButton("Cancel");
btnCancel.setActionCommand("CANCEL");
btnCancel.addActionListener(this);
JPanel pnlBottom = new JPanel();
pnlBottom.setLayout(new BoxLayout(pnlBottom, BoxLayout.X_AXIS));
pnlBottom.setBorder(BorderFactory.createEmptyBorder(25,55,0,0));
pnlBottom.add(btnSave);
pnlBottom.add(Box.createRigidArea(new Dimension(25,0)));
pnlBottom.add(btnCancel);
pnlMain.add(pnlBottom);
this.setContentPane( pnlMain);
setSize(500,500);
GraphicUtilities.center(this);
theABC=ABC.getABC();
//Do I call my ABC singleton class correctly??
private void loadPersonalInfo()
String ID= System.getProperty("user.name");
SimpleUser user = null;
try {
user = ABC.getID(ID);
//I tried to use method in ABC singleton class. IS this correctly call?
} catch(UserNotFoundException nfe)
JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered.",
"User Not Found",JOptionPane.WARNING_MESSAGE);
System.exit(0);
} catch(DelegateException de) {
JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",JOptionPane.ERROR_MESSAGE);
System.exit(0);
currentUser = user;
txtFname.setText(currentUser.getFirstName());
txtLname.setText(currentUser.getLastName());
//This information will be display in my textfields Fname and Lname
//I can change my first and last name and hit button SAVE to save
public void actionPerformed(ActionEvent e)
if(e.getActionCommand().equals("SAVE")) submitChanges();
if(e.getActionCommand().equals("CHANGE_PASSWORD")) {
changepassword=new ChangePassword(new Frame(),name,badgeid);
public void submitChanges(){
String currentNTUsername = System.getProperty("user.name");
SimpleUser user =null;
try {
user = theABC.getID(ID);
user.setFirstName(txtFname.getText().trim());
user.setLastName(txtLname.getText().trim());
currentUser = user;
theABC.updateUserInfo(currentUser);
//IS this correctly if I want to use this method in singleton class ABC??
} catch(UserNotFoundException nfe)
JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",
"User Not Found",JOptionPane.WARNING_MESSAGE);
} catch(DelegateException de) {
JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",JOptionPane.ERROR_MESSAGE);
System.exit(0);
this.setVisible(false);
3) click on ChangePassword in my above GUI class A..will call this class B..and in this class B
I need to access method in a Singleton class- ABC class,,DO i need to inititates it agian, if not what should I do? thanks
package com.lockheed.vista.userinfo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
import javax.swing.tree.*;
import java.util.StringTokenizer;
import java.util.Vector;
import java.io.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.colorchooser.*;
import javax.swing.filechooser.*;
import javax.accessibility.*;
import java.beans.*;
import java.applet.*;
import java.net.*;
import org.apache.log4j.*;
import com.lockheed.common.gui.GraphicUtilities;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import vista.user.UserServicesDelegate;
import vista.user.SimpleUser;
import vista.user.UserNotFoundException;
import vista.user.*;
import com.lockheed.common.ejb.*;
import com.lockheed.common.gui.*;
import com.lockheed.vista.publish.*;
* This program allow users to change their Vista Web Center's password
public class ChangePassword extends JDialog
implements ActionListener{
protected final Logger log = Logger.getLogger(getClass().getName());
private UserServicesDelegate userServicesDelegate;
private User currentUser = null;
private JPasswordField txtPasswd, txtVerifyPW;
private JButton btnSubmit,btnCancel;
private JLabel lblName,lblBadgeID;
private String strBadgeID="";
* This is the constructor. It creates an instance of the ChangePassword
* and calls the method to create and build the GUI.
public ChangePassword(Frame owner,String name,String badgeid)
super(owner, "Change Password",true);
initScreen(name,badgeid);//build the GUI
* This method instantiates all the GUI widgets and places them into panels and
* onto the frame.
private void initScreen(String strname,String strBadgeid)
txtPasswd = new JPasswordField(20);
txtVerifyPW=new JPasswordField(20);
txtPasswd.setEchoChar('*');
txtVerifyPW.setEchoChar('*');
JPanel pnlMain=new JPanel();
pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.Y_AXIS));
pnlMain.setBorder(BorderFactory.createEmptyBorder(20,0,20,0));
JPanel pnlPW=new JPanel();
pnlPW.setLayout(new BoxLayout(pnlPW, BoxLayout.X_AXIS));
pnlPW.setBorder(BorderFactory.createEmptyBorder(0,96,0,30));
pnlPW.add(new JLabel("Password:"));
pnlPW.add(Box.createRigidArea(new Dimension(5,0)));
pnlPW.add(txtPasswd);
JPanel pnlVerifyPW=new JPanel();
pnlVerifyPW.setLayout(new BoxLayout(pnlVerifyPW, BoxLayout.X_AXIS));
pnlVerifyPW.setBorder(BorderFactory.createEmptyBorder(0,63,0,30));
pnlVerifyPW.add(new JLabel("Verify Password:"));
pnlVerifyPW.add(Box.createRigidArea(new Dimension(5,0)));
pnlVerifyPW.add(txtVerifyPW);
JPanel pnlTop= new JPanel();
pnlTop.add(pnlPW);
pnlTop.add(Box.createRigidArea(new Dimension(0,10)));
pnlTop.add(pnlVerifyPW);
pnlMain.add(pnlTop);
btnSubmit = new JButton("Submit");
btnSubmit.setActionCommand("SUBMIT");
btnSubmit.addActionListener(this);
btnCancel = new JButton("Cancel");
btnCancel.setActionCommand("CANCEL");
btnCancel.addActionListener(this);
JPanel pnlBottom = new JPanel();
pnlBottom.setLayout(new BoxLayout(pnlBottom, BoxLayout.X_AXIS));
pnlBottom.setBorder(BorderFactory.createEmptyBorder(25,55,20,30));
pnlBottom.add(btnSubmit);
pnlBottom.add(Box.createRigidArea(new Dimension(25,0)));
pnlBottom.add(btnCancel);
pnlMain.add(pnlBottom);
this.setContentPane( pnlMain);
setSize(350,230);
setVisible(true);
public void actionPerformed(ActionEvent e)
if(e.getActionCommand().equals("CANCEL")) this.setVisible(false);
if(e.getActionCommand().equals("SUBMIT")) submitPW();
* This method is called when the submit button is clicked. It allows user to change
* their password.
public void submitPW(){
myABC= ABC.getABC();//Is this correct?
char[] pw =txtPasswd.getPassword();
String strPasswd="";
for(int i=0;i<pw.length;i++){
strPasswd=strPasswd+pw;
char[] vpw =txtVerifyPW.getPassword();
String strVerifyPW="";
for(int i=0;i<vpw.length;i++){
strVerifyPW=strVerifyPW+pw;
if((strPasswd==null)||(strPasswd.length()==0)) {
JOptionPane.showMessageDialog(new JDialog(),"You have not enter a password. Please try again.",
"Invalid Password",JOptionPane.ERROR_MESSAGE);
if((!strPasswd.equals(strVerifyPW)))
//password and verify password do not match.
JOptionPane.showMessageDialog(new JDialog(),"Your passwords do not match. Reenter and try again.",
"Invalid Password",JOptionPane.ERROR_MESSAGE);
try
myABC.setUserPassword(strPasswd);//try to use a method in Singleton class
txtPasswd.setText("");
txtVerifyPW.setText("");
this.setVisible(false);
} catch(DelegateException e) {
JOptionPane.showMessageDialog(new Frame(),
"Error.",
"Unable to change password information.",JOptionPane.WARNING_MESSAGE);
} catch(UserNotFoundException e) {
JOptionPane.showMessageDialog(new Frame(),
"Error.",
"Unable to change password information.",JOptionPane.WARNING_MESSAGE);
And ofcourse I have other EJB classes to work with these classes.
***It compiles okey but when I ran, it say "NullPointerException"
I think I call my Singleton wrong.
Please help me.thanks

1. When replying, use <reply>, don't post a new topic.
2. Implementing a singleton is a frequently asked question. Search before you post.
3. This is not a question about Swing. A more appropriate forum would be "New To Java Technology" or perhaps "Java Programming", but see point 1.
4. When posting code, keep it short. It increases the chance of readers looking at it. And in composing your shorter version for the forum, you just may solve your problem.

Similar Messages

  • How do I get about:config and other about: addresses to drop down from URL bar?

    How do I get about:config and other about: addresses to drop down from URL bar?
    It's a pain having to retype them in full... not sure why there is no easier interface to them.

    hello, you can bookmark the sites for faster access.
    [[How to use bookmarks to save and organize your favorite websites]]

  • Concerns about Singleton classes in EAR archive

    Let's say I have an EAR file with the following structure:
    employee.jar<br>
    employeeSearchEJB.jar<br>
    webApp1.war<br>
    webApp2.war<br>
    META-INF<br>
    application.xml<br>
    If there is a singleton class in the employee.jar utility archive, then does there
    exist a single instance of that singleton class for each web application in
    the EAR? I hope not because that would seriously screw things up with me. I would
    be upset, to say the least.
    SAF

    I tested it out, and you're right, only 1 instance of the singleton exists at the
    EAR level.
    Thanks,
    SAF
    "mike iwaskow" <[email protected]> wrote:
    >
    If there is a singleton class in the employee.jar utility
    archive, then does there exist a single instance of that
    singleton class for each web application in
    the EAR ?
    Based on your scenario, I believe the answer is "No".
    I'm knowledgeable with WLS 5.1 and up, not 4.51.
    Your best bet is to give it a try. If a problem does occur,
    contact BEA support at [email protected]
    Developer Relations
    BEA Support

  • L.G. Schneider and others: About CS6 and CS5.5

    I am well behind the curve and ashamed. Be that as it may, I remain on OS10.6.8. AICS5.5 has performed well for me, and being the risk-averse coward that I am, I've stuck with what has worked. On a lark, today I downloaded AICS6, haunted all the while by memories of posts here about folks returning to 5.5 because of 6's (and then CC's) problems and insufficiencies.
    Pattern maker and gradients  on a stroke in CS6 are pleasing additions. I'm sure I'll find others. But can I trouble you for a brief overview of the deficiencies and setbacks in CS6 relative to 5.5? It would be helpful as I try to navigate from ancient software history to slightly less ancient software history.

    Always value hearing from you, Monika.
    I see the significant differences between the tracing features in CS5 and CS6. And now that you mention it, I recall some folks reporting some aspects of the CS6 version being better, some worse. But no GLITCHES in the newer version that I recall.
    And yes, the potential Pantone problem is easily remedied.
    Not to beat a dead horse, but I thought there had been reports of some bona fide DEFICIENCIES and BUGS in CS6 and maybe a few useful features that had been REMOVED from prior versions or that are PERFORMING LESS WELL. For example, one that I recall is that you can no longer select multiple layers in the Layers Panel by option-dragging through them (a pity).
    Oh well. I'd posted the question looking for other such changes to be aware of (I know it's been a while since CS6 was "the version").

  • Singleton class issue

    I have a singleton class. A method in this class creates an array of structures. This class is shared across different process. So there is a chance that some one unknowigly calls the method to create the array of structures and hence the member variable may now points to another array of structure.
    Is there any way in Java to restict invoking of a function only once.
    A static variable with a check will solve this issue, but any other method so that calling of method itself becomes invalid to avoid RT usage?.

    Hi,
    I think, I understood know.
    You want to have a singleton holding a defined number of other objects (your arrays).
    This objects (your arrays) are semantically singletons itsself, because they should be constructed only once and than reused.
    Assuming I interpreted right, see my comments inline below.
    I know that who ever participate in this discussion is
    pretty sure about singleton class. Some of the code
    what I gave was irretating as Martin pointed out. So
    let me try to give more transparent code snippet,Thanks, that helped.
    >
    My aim :- I need a global object which is going to
    hold some arrays(data structures). This should be
    shared across various threads. (forget about the
    synchronousation part here). All these arrays won't be
    of same size, so I need methods for each
    datastructures to initialise to its required size.That's a little bit part of your problem, see below.
    My wayforward :- Create the global object as
    singleton. This object has methods for initialising
    different data structures.OK, fine.
    What is my doubt :- please see the following code
    fragment,
    public class Singleton {
    private Singleton singleton;
    private Singleton() {
    public static Singleton getInstance() {
    if (singleton == null) {
    singleton = new Singleton();
    return singleton;
    //other methods for the class
    private someObjType1 myArray1 = null;
    private someObjType2 myArray2 = null;
    private someObjType3 myArray3 = null; // etc....This "smells" like an candidate for another data structure, so that you don't have a fixed number of array.
    F.E.
    // Associate class of array elements (someObjTypeX) as keys with arrays of someObjTypeX
    private Map arrayMap = new HashMap();>
    public void CreateArray1(int size) {
    if (myArray1 == null) {
    myArray1 = new someObjType1[size];
    }Using the map, you create array should look like
    public void CreateArray(Class clazzOfArrayElem, int size)
      Object arr = arrayMap.get(clazzOfArrayElem)
      if(arr == null)
        arr = java.lang.reflect.Array.newInstance(clazzOfArrayElem, size);
        arrayMap.put(clazzOfArrayElem, arr);
    }Additionally the "ugliness" of this method results from the problem, that don't know the size of arrays at compile time.
    So it seem to be preferable to use a dynamic structure like a Vector instead of array. Then you don't have the need to pass the size in the accessor method.
    Then you can use a "cleaner" accessor method like
    public Vector getVector(Class clazzOfArrayElem)
      Vector vec = arrayMap.get(clazzOfArrayElem)
      if(vec == null)
        vec = new Vector();
        arrayMap.put(clazzOfArrayElem, vec); 
    return vec;
    }If you want to expose an array oriented interface f.e. for type safety you can have an accessor like
    public Object[] getAsArray(Class clazzOfArrayElem)
      Vector vec = arrayMap.get(clazzOfArrayElem)
      if(vec == null)
        vec = new Vector();
        arrayMap.put(clazzOfArrayElem, vec);
      arr = java.lang.reflect.Array.newInstance(clazzOfArrayElem, 0);
      return (Object[])vec.toArray(arr);
    // Real typesafe accessors as needed following
    public SomeClass1[] getAsArrayOfSomeClass1()
      return (SomeClass1[])getAsArray(SomeClass1.class);
    /.....This accessor for array interface have the additional advantage, that they return a copy of the data (only the internal arrays, no the object within the arrays!), so that a least a client using your class doesn't have access to your internal data (with the Vector he has).
    >
    // similarly for other data structures...
    So here CreateArray1 method will work fine because of
    the check myArray1 == null.
    Actual question :- Can I remove this check and
    restrick call to CreateArray1 more than one time ?.No. As I understood you want to have something like a "only-use-once-method". There is no such thing in Java I know of.
    But I don't see the need to remove this check. Reference comparison should have no real impact to the performance.
    this is going to benifit me for some other cases
    also.How?
    Hope this helps.
    Martin

  • I've been reading the comments re FCPX on MacBook Pro and now I'm scared. I'm taking a class now and thinking about buying to do videos for nonprofits. Won't be fancy stuff, but now wonder if it's a good choice. Also, heard Apple will drop support. Help?

    I've been reading the comments re FCPX on MacBook Pro and now I'm scared. I'm taking a class in FCPX and thinking about buying to do videos for nonprofits. Won't be fancy stuff, but now wonder if it's a good choice. Also, a classmate who was in CA last weekend said he heard that Apple will drop support of FCPX. Any truth? Advice?. I'm on 10.7.4 with 2.4 GHz Intel Core 2 Duo, 4 GB 1067 MHz. Thanks.    

    dkstj wrote:
    Also, a classmate who was in CA last weekend said he heard that Apple will drop support of FCPX.  
    While it is against the TOU of these boards to speculate on future products/updates what Thomas said is right: FCPX is quite a new product and it doesn't make any sense to drop it now.
    The only thing that MIGHT get dropped at a certain point is support for older hardware/OS as FCP X progresses.

  • Question about abstract classes and instances

    I have just read about abstract classes and have learned that they cannot be instantiated.
    I am doing some exercises and have done a class named "Person" and an abstract class named "Animal".
    I want to create a method in "Person" that makes it possible to set more animals to Person objects.
    So I wrote this method in class Person and compiled it and did not get any errors, but will this work later when I run the main-method?
    public void addAnimal(Animal newAnimal)
         animal.add(newAnimal);
    }Is newAnimal not an instance?

    Roxxor wrote:
    Ok, but why is it necessary with constructors in abstract classes if we don�t use them (because what I have understand, constructors are used to create objects)?Constructors don't create objects. The new operator creates objects. An object's c'tor is invoked after the object has already been created. The c'tors job is to initialize the newly-created object to a valid state. Whenever a child object is created, the parent's c'tor is run before the child's c'tor, so that by the time we're inside the child's c'tor, setting up the child's state, we know that the parent (or rather the "parent part" of the object we're initializing) is in a valid state.
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Singleton class for logging in the application, and setting the flag

    Hi Friends,
    I have a singleton class for logging in the application, and setting the flag once logged. can some one help me in doing this.
    with regards,

    rtfm, for example here - http://www.javacamp.org/designPattern/

  • Question about synchronized singleton classes

    Hi,
    I have a singleton class, with only 1 method (which is static), I want access to that method to be synchronized, but someone suggested that I make my getInstance() method synchronized as well.
    Is this neccessary, or is it overkill?
    thanks!

    Example:
    static Instance getInstance() {
    if (instance == null) {
    instance = new Instance();
    return instance;
    }Two threads call it simultaneously:
    1. if (instance == null) { // evaluates true
    2. if (instance == null) { // evaluates true
    1. instance = new Instance(); // first instance
    2. instance = new Instance(); // second instance,
    deleting the reference to the first instance
    1. return instance; // which is not the originally
    created one but the second instance
    2. return instance;There's actually a worse consequence.
    1) T1 sees null
    2) T1 sets instance to point to where the object will live
    4) T2 sees non-null
    3) T2 returns, with a pointer to what's supposed to be an object, but isn't yet inited.
    4) T1 eventually inits the instance
    This can happen even if you use the "double check locking" pattern of synchronization.
    At least under the old memory model. I think the new JMM in effect in 5.0 (and possibly later 1.4) versions fixes it. I don't know if the fact that it can happen in absence of sync/DCL is an error or not, so I'm not sure if that's addressed in the new JMM, or if it's only the synced case that was a bug. (That is, it might be okay that it happens without syncing.)

  • HT4865 So who believes Apple should be a bit more cautionary about the sharing of iMessages and other content when several members of a family share the same iCloud account and unknowing can audit each other's iMessages, Contacts, and god only knows what

    I think Apple should be a bit more cautionary about iCloud and privacy.  My family shares the same iCloud account as we all enjoy the music we collectively purchase on iTunes; we paid Apple for this feature with some kind of grouped account.  We didn't know, however that this joins our devices so that iMessages, contacts, pictures and just about everything else is shared too.  The unprivate default seems to be to share everything between all devices vs. to allow access by exception or by choice (or by password?).  Sure, when my kids get all my texts I can go figure out why and fix it but that is in my mind the antithesis of privacy and could be quite embarrassing for any family.  I guess it is good for stalking the kids or parents though if they don't know about the partyline approach to privacy.  Maybe a tech solution would be to have the iPhone show somehow the extent of its audience to its user.

    No argument from me about the vagaries of using and sharing Apple IDs.  This can lead to unintended consequences, especially in a family situation.
    If you're sharing the same ID for FaceTime, you might want to go to Settings>FaceTime, tap the ID, sign out, then sign in with separate IDs there too.  Otherwise, you'll end up getting each other's FaceTime calls.
    Also, if you need to migrate everyone's devices to separate iCloud accounts to keep your synced data separated, you can do this by saving any photo stream photos you wish to keep to your camera roll (unless already there) by opening your my photo stream album, tapping Select, tapping the photos, tap the share icon (box with upward facing arrow), then tapping Save to Camera Roll.  If you are syncing notes with iCloud, you'll need to open each of your notes and email them to yourself so you can later copy and paste the text into new notes created in your new account.  Then go to Settings>iCloud, tap Delete Account (which only deletes it from this device, not from iCloud), choose Keep on My iDevice and provide the password to turn off Find My iPhone.  Then sign back in with a different Apple ID to create your new account and choose Merge to upload your data.  Once everyone's devices are on separate accounts, you can go to icloud.com and delete each other's data from your accounts.

  • Document Classes and other Questions

    Basically, i am working on an application that will eventually be deployed to the desktop as an AIR application.
    I am wanting to create an Analogue clock and Digital clock with a button that toggles the display between either one when pressed. As well as this, i will be wanting to display the Date below, i am having a number of issues however.
    I have the code sorted for three of the four components, i have not attempted to figure out the button thus far as i would be more than happy to have the digital clock, analogue clock and date all being displayed on a drag and drop desktop application first. When i say i have it sorted, i have a fully working analogue clock which i have managed to display on the desktop through air on its lonesome, however, i did not include the drag and drop function. For the digital clock and date components i am not sure how to configure them into document classes. The main issue i am having is i do not know if you can reference a dynamic text box within a movie clip to a document class.
    This is the code to show the date
    [code]{
    var currentTime:Date = new Date();
    var month:Array = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");
    var dayOfWeek:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    date_text.text = dayOfWeek[currentTime.getDay()] + " " + currentTime.getDate() + " " + month[currentTime.getMonth()] + " " + currentTime.getFullYear();
    [/code]
    I have put the actionscript frame inside the movie clip file, and i have given both the movie clip, and the dynamic text box within the movie clip the instance name "date_text".
    Basically, i am just struggling in how to put this code into a working document class, since the digital clock and date functions are both, some what similar, i feel the solution to one will more than likely lead to me discovering the solution for the other.
    The other problem i am having, i do not know how i will display all of the components on one air application. I am assuming, that you create one other document class file which links the other four together? i have tried to do this by just linking a new FLA file with the analogue clock, but it does not work. The code for that is below.
    [code]package
              import flash.events.Event;
              import flash.display.MovieClip;
              public class time1 extends MovieClip
                        public var now:Date;
                        public function time1()
                                  // Update screen every frame
                                  addEventListener(Event.ENTER_FRAME,enterFrameHandler);
                        // Event Handling:
                        function enterFrameHandler(event:Event):void
                                  now = new Date();
                                  // Rotate clock hands
                                  hourHand_mc.rotation = now.getHours()*30+(now.getMinutes()/2);
                                  minuteHand_mc.rotation = now.getMinutes()*6+(now.getSeconds()/10);
                                  secondHand_mc.rotation = now.getSeconds()*6;
    [/code]
    That is the original clock document class (3 Movie clips for the moving hands, and the clock face is a graphic, which i may have to reference somehow below)?
    [code]package
              import flash.display.MovieClip;
              public class main extends MovieClip
                        public var hourHand_mc:time1;
                        public var minuteHand_mc:time1;
                        public var secondHand_mc:time1;
                        public function main()
                                  hourHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  hourHand_mc.x = 75;
                                  hourHand_mc.y = 75;
                                  minuteHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  minuteHand_mc.x = 75;
                                  minuteHand_mc.y = 75;
                                  secondHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  secondHand.x = 75;
                                  secondHand.y = 75;
    }[/code]
    This is my attempt at creating the main document class in a seperate FLA file to attempt to load the analogue clock, and later on the Digital Clock, Date Function and Toggle Display button in the same AIR application.
    Any help on this is much appreciated, i have been reading up a lot on it through tutorials and the like, but i can't seem to fully grasp it.

    why do you have code in a movieclip?
    if you want to follow best practice and use a document class you should remove almost all code from timelines.  the only timeline code that might be reasonably used would be a stop() on the first frame of multiframe movieclips.
    so, you should have a document class.  that could contain all your code but it would be better to just have your document class create your 2 clocks and date objects and possibly manage toggling between the two clocks.  you could have a separate class the tracks the time and date and that class is used by your two clock classes and your date class.

  • Recently, iTunes upgraded.  My 7th generation iPod is now not recognized and I cannot sync.  The troubleshooting talks  about being visible in Windows (iPod is invisible)  No other options and nothing about windows 8

    Recently, iTunes upgraded.  My 7th generation iPod is now not recognized and I cannot sync.  The troubleshooting talks  about being visible in Windows (iPod is invisible)  No other options and nothing about windows 8

    I have had similar issues with mine, happens mainly if I transfer songs and then decide to disconnect my iPod to listen to them with my IEMs (I use Interenet Explorer in my case and it is not neccessarely up when this happens, so I seriously doubt it is an issue conencted to the web browser). I have no patience for this so my trick is I try to eject it from iTunes, if that does not work, then I bring Windows explorer up, right mouse click on the iPod mounted drive and select Eject. It gives me the same warning but there is a third button selection called Continue. When I choose that it just disconnets the drive anyway and the iPod is finally disconnected. It seems to work each and every time I do it so this solution is fine for me. Would be intersting to see what the real root cause of this is because I started getting this problem with the newer iTunes 11.

  • About 1 year ago, I can not access the App Store. The message that appears is: "One Moment Please. Connecting to the iTunes Store. Loading ... I've tried all the aids presented in this and other forums and nothing solves. iTunes connects normaly...

    About 1 year ago, I can not access the App Store. The message that appears is: "One Moment Please. Connecting to the iTunes Store. Loading ... " I've tried all the aids presented in this and other forums and nothing solves. iTunes connects normaly...

    Your profile indicates your Mac is running v10.7.2
    If that is correct, updating your system software may help.
    Click Software Update from the Apple menu.
    Restart your Mac after updates are installed then try the App Store.
    If you can't update that way, there's a workaround.
    Install the OS X Lion Update 10.7.5 (Client Combo)
    Then restart your Mac and try the App Store.
    messaged edited by:  cs

  • If i upgrade to mountain lion (from lion), will i need to reinstall my windows VM? and what about my apps and other stuff? will those need to be reinstalled too?

    if i upgrade to mountain lion (from lion), will i need to reinstall my windows VM? and what about my apps and other stuff? will those need to be reinstalled too?

    I started off with problems about being in the wrong region and now  have Plug- in Failure
    I am trying to access Setanta Sports Australia which requires
    Microsoft Silverlight and was already pre-installed on a Macbook Pro Retina 2.5 ghz Intel core i5 with Mountain Lion 2.8.3
    I have these different PlugIns active :
    file://localhost/Library/Internet%20Plug-Ins/DivXBrowserPlugin.plugin/
    file://localhost/Library/Internet%20Plug-Ins/Flash%20Player.plugin/
    file://localhost/Library/Internet%20Plug-Ins/JavaAppletPlugin.plugin/
    file://localhost/Library/Internet%20Plug-Ins/QuickTime%20Plugin.plugin/
    file://localhost/Library/Internet%20Plug-Ins/Silverlight.plugin/

  • My i4s wifi button is not working. when i opened the setting and then wifi the button is greyed out. then i opened general and then about. in the bar of wifi address it is written N/A. what does its mean. i have done all other things like setting general

    my i4s wifi button is not working. when i opened the setting and then wifi the button is greyed out. then i opened general and then about. in the bar of wifi address it is written N/A. what does its mean. i have done all other things like setting >general<reset<reset network setting. but all in vain. tell me the solution

    restore your phone as new through itunes. if the issue persists after a factory restore via itunes, it means you've got a hardware issue and the phone needs to be repaired

Maybe you are looking for