Question about synchronized

Hello everyone,
Suppose I have a method which is a synchronized method (for example, method Foo in the following code block), and in this synchronized method another method which is not synchronized is invoked (for example, method Goo in the following code block). I am wondering when executing in Goo from Foo, whether we still have the synchronized feature (i.e. obtain the lock of "this" object).
synchronized public Foo()
    Goo();
private Goo()
}Thanks in advance,
George

Kaj,
Hi, pls see my post above - I replied to the same question in the other forum and I was pretty sure about my answer until I found it different from ur reply here.
Here is my reply. Can u kindly guide me to what's wrong in it ?
if a lock on a sync-ed method extends to all methods being called from it, then the jvm (bcos it has no means of knowing until runtime the method calls from a sync method) has to lock all the methods in a class that has atleast one sync method.
What this would mean potentially is that the effect of sync-ing one method would be equal to sync-ing all the methods bcos any of the other methods could be potentially called from the sync-ed one.
The example below is co-erced, but serves to illustrate the point.
     public class Test
    synchronized public  void Foo()
        Goo();
    synchronized public  void Moo()
        Goo();       
        notify();
    private void Goo()
        System.out.println(Thread.currentThread().getName()+" accessing goo");
        try
            if(Thread.currentThread().getName().equals("Th one"))
                 //force thread1 to wait , lets see if thread2 can access it while thread1's waiting on it
                wait();
        catch(Exception e){}
        System.out.println(Thread.currentThread().getName()+" returning from goo");
//first thread
public class MyT implements Runnable
    Test t;
    public MyT(Test t)
        this.t = t;
    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
    public void run()
        t.Foo();
//second thread
public class MyT2 implements Runnable
    Test t;
    public MyT2(Test t)
        this.t = t;
    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
    public void run()
        t.Moo();
//Main
public class Main
    public static void main(String[] args)
        Test t = new Test();
        Thread th = new Thread(new MyT(t),"Th one");
        Thread th1 = new Thread(new MyT2(t), "Th two");
        th.start();
        th1.start();       
And the o/p I got was
Th one accessing goo/*thread one in goo, is in wait() coz of the funny if clause there*/
Th two accessing goo /*there's no lock on goo, else with thread one in wait(), this wouldve been impossible*/
Th two returning from goo/*Thread 2 is over with Goo(), will go back and notify Thread 1*/
Th one returning from goo/*Thread 1 is notified, wakes up and returns :-)*/
tx,
ram.

Similar Messages

  • Question about "synchronized" and "wait"

    Hello, everyone!
    I have seen a piece of code like this,
    synchronized (lock)
    //do operation 1
    lock.wait();
    //do operation 2
    I think in the above piece of code, when a thead finished operation 1, it will release the lock and let other threads waiting for the lock have chance to run the same block of code. Am I correct?
    If I am correct, I have a further question, a "synchronized" block means a set of operations that can not be interrupted, but when invoke "wait" method, the thread running in the "synchronized" block will be terminated (interrupted) by release the lock and other threads will have chance to enter the "synchronized" block. In short, the execution inside the "synchronized" block will be interrupted. So, I wonder whether the above piece of code is correct and conforms to the principle of "synchronized". And what is its real use?
    Thanks in advance,
    George

    Thanks, pkwooster buddy!You're welcome
    I just wondered whether "wait inside a synchronized
    block" technology is thread safe. Please look at the
    following example,wait and synchronized are thread safe.
    public class Foo {
    int mVal= 0;
    public final Object mLock = ...;
    public void doIt() {
    synchronized(mLock) {
    mVal = ...;
    mLock.wait();
    if (mVal == ...) {
    // do something
    } else {
    // do something else
    }If we have two threads, T1 and T2, enter the block in
    their respective order, and T1 is woken up first, T2
    may have tampered with T1's execution path because T2
    changed mVal while T1 was asleep. So T2 manipulate
    instance field mVal is a side-effect.when you do the wait() you give up the lock and the other threads get a chance to run. When you exit the wait() you get the new value of the myVal variable which may have been changed. This is exactly what you want. To make that not thread save you could do
    int temp = myVal;
    wait();
    if(temp == ...)in this case the variable temp contains the old vale of myVal.
    >
    I think the most safest way is never wait inside a
    synchronized block, but it is less efficient. What do
    you think about the trick of wait inside a
    synchronized block? I think you are very experienced
    in thread field from your kind reply.
    Thanks in advance,
    Georgewait(), notify() and notifyAll() are very useful. You need them when you want threads to cooperate in an predictable manner. I recommend that you review the section on consumer and producer classes and wait and notify in the Threads Tutorial. It gives good examples. For a practical example of this you could also take a look at my Multithreaded Server Example. It implements a simple chat server that switches String messages. Look especially at the send(), doSend() and popMessage() methods in the StreamConnection class. These allow the receive thread of one user to send messages out using the send thread of another user. If you have questions about that example, please post the questions on that topic.
    Hope this helps.

  • Question about synchronized re-entry

    Suppose I have the following code:
    * method performs actions that require synchronization on state but
    * the programmer ensures manually that it is only called in a context
    * where we are already synchronized on state
    private void veryPrivateMethod() {
        //synchronized(state) { (*) required?
        if (state == 999) {
            // perform actions that require synchronization on state
    public void anotherMethod() {
        synchronized(state) {
            if (state == 42)
                state = 43;
            veryPrivateMethod();
    }See (*): If I ensure manually that veryPrivateMethod will only be called in a context where we are already synchronized on state, do I still need to specifically synchronize on state in the method (reentrant synchronization), or will it be better performance-wise and still safely synchronized if I omit the synchronized statement in veryPrivateMethod()?
    Thanks!

    gimbal2 wrote:
    932196 wrote:
    I synchronize on it whenever I change / compare-change it. Is this a bad ideaThat's a maybe. Its not a bad idea, as long as you realize that doing this has no special meaning and will offer no special protection. You can synchronize on just about any object you want, as long as other threads synchronize on the exact same object when wanting to execute the same section(s) of volatile code.the comment in the example is:
    // perform actions that require synchronization on statethis leads me to believe that the code is not correctly synchronized currently. like i said, changing the reference to the object you are synchronizing on pretty much always leads to broken code.

  • Question about synchronized static function.

    Hi, everyone!
    The synchronized statement often deals with an object (called monitor).
    But a static function can be invoked without an object.
    So if a static function is declared as static, what is the function of
    static and synchronized here? Which lock it is using?
    Can you give me a simple expplanation?
    regards,
    George

    Hence try and avoid synchronizing static methods.
    Try and use non static method if you are doing
    multithreaded programming. That way you can have lockWell, I avoid static methods, not just when doing multithreading, but not for the reason you mention.
    objects which allow non interfering methods to be
    accessed in parallelThats easy to do with static methods anyway:
    class Foo
      static Object lock1 = new Object();
      static Object lock2 = new Object();
      static void method1()
         synchronized( lock1 )
      static void method2()
         synchronized( lock2 )
    }Maybe I just missunderstod you...

  • Question about synchronizing two methods...

    i have 2 methods:
    writeData() //method 1
    createNewDataFile() //method 2
    the main thread will be using method 1 quite frequently. In method 2, a separate thread will be waking up every 10 minutes or so and doing some maintenance on the file written to in method 1. So, when the thread is in method 2 i need method 1 to standby and wait. I also want the opposite, that when the main thread is in method 2 method 1 will stand by.
    Any help is appreciated!

    799454 wrote:
    So wait,
    i thought synchronized only worked on the actual methods where it is declared:Using the synchronized keyword obtains a lock. Each object has exactly one lock associated with it. Once a thread has obtained an object's lock, no other thread can obtain that lock (and hence cannot enter a sync block on that lock) until the first thread releases it by leaving its sync block or calling wait().
    so, you're saying that if i declare:
    synchronized method 1
    synchronized method 2
    then i have a single object with 2 synchronized methods, so if thread A is in EITHER of those methods, the other method will be locked as well?The method isn't "locked" per se, but yes, 1 object, 2 synced methods, if T1 is in either method, then T2 cannot enter either method.
    I strongly urge you to go through that tutorial and/or a book on Java concurrency, thoroughly.

  • 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.)

  • A question about synchronized Lists...

    If I have a synchronized list, and I have a synchronized block in one thread with a lock on that list (synchronized(List)) am i supposed to be able to add an item to that list directly (using the List.add() method) from another thread while I'm still in the synchronized block previously described?
    I have some code here where I tried to test that and the answer that I got is that it is possible while (I believe) it's not possible theoretically speaking.
    import java.util.*;
    public class Warehouse implements Runnable{
         List<String> items = Collections.synchronizedList(new ArrayList<String>());
    //     List<String> items = new ArrayList<String>();
         public static void main(String[] args){
              Warehouse w = new Warehouse();
              Manager m = new Manager(w);
              Thread one = new Thread(w);
              Thread two = new Thread(m);
              one.start();
              two.start();
         public void add(String t){
              synchronized(items){               
                   for(int i=0; i<2; ++i){
                        System.out.println("Warehouse added item...");
                        try{
                        Thread.sleep(500);
                        }catch(InterruptedException ie){
                             ie.printStackTrace();
                   items.add(t);
                   items.notify();
         public void run(){
              for(int i=0; i<1; ++i){
                   synchronized(items){
                        while(items.isEmpty()){
                             try{
                             System.out.println("Warehouse waiting...");
                             items.wait();
    //                         System.out.println("Warehouse after waiting...");
                             for(int j=0; j<2; ++j){
                                  System.out.println("Warehouse after waiting...");
                                  try{
                                  Thread.sleep(500);
                                  }catch(InterruptedException ie){
                                       ie.printStackTrace();
                             }catch(InterruptedException ie){
                                  ie.printStackTrace();
    class Manager implements Runnable{
         Warehouse w;
         public Manager(Warehouse w){
              this.w = w;
         public void run(){
              for(int i=0; i<1; ++i){               
                   System.out.println("Manager Adding item...");
                   w.add("articulo");                              
                   for(int j=0; j<5; ++j){
                        w.items.add("jeje");
                        try{
                        Thread.sleep(500);
                        }catch(Exception ex){ex.printStackTrace();}
                        System.out.println("Manager adding to items");
                   System.out.println("Manager finished with warehouse...");
    }Output:
    Warehouse waiting...
    Manager Adding item...
    Warehouse added item...
    Warehouse added item...
    *Warehouse after waiting...*
    *Manager adding to items*
    *Warehouse after waiting...*
    *Manager adding to items*
    Manager adding to items
    Manager adding to items
    Manager adding to items
    Manager finished with warehouse...The code in "bold" (with the tokens) isn't supposed to happen concurrently as I understand it since the "warehouse after waiting" statement it's in the synchronized block with a lock on the items list and the "manager adding to items" statement is adding an item to that list through a direct reference to that list...

    When the manager thread notifies the items (warehouse thread), the warehouse thread does not have to wake up automatically, it has to compete for the items lock then wait for its Thread context to execute. Which means that the manage is able to continue to execute - adding to items manually, and eventually sleep()ing. When the manager thread sleeps that is a good place for a Thread context switch, and if the JVM takes that opportunity to do so, then the warehouse thread regains the lock and would prevent further access to items. But at some point the Thread context will switch again (probably when warehouse thread goes to sleep). Now the manager thread can wake up, print that it is working because that code is not protected by any synchronized lock. Then when it attempts to add to items again it blocks. Another thread context switch allows the warehouse to complete its work, finish up, and release the items lock. Manager can then get the lock on items and finish its work. The results would be exactly as you display them. Here is a possible walk-through of the threading paths taken:
    Thread == Warehouse
    i = 0
      lock on items
        items.isEmpty == true
          print "Warehouse is waiting"
          items.wait (unlock items)
    /* CONTEXT SWITCH */
    Thread == Manager
    i = 0
      print ""Manager Adding item..."
      locking items
        i = 0
          printing "Warehouse added item..."
          sleeping 500
        i = 1
          printing "Warehouse added item..."
          sleeping 500
        i ! < 2
        locking items
          adding to items
        unlocking items
        notifying items (wait will unlock eventually)
      unlocking items
      j = 0
        locking items
          adding to items
        unlocking items
        sleeping 500
    /* CONTEXT SWITCH */
    Thread == Warehouse
          items.wait (regain lock and get context)
          j = 0
            prinitng "Warehouse after waiting..."
            sleeping 500
    /* CONTEXT SWITCH */
    Thread == Manager
        sleeping 500 is done
        printing "Manager adding to items"
      j = 1
        locking items (blocking until items is available)
    /* CONTEXT SWITCH */
    Thread == Warehouse
            sleeping 500 is done
          j = 1
            printing "Warehouse after waiting..."
          j ! < 2
        itemse ! isEmpty
      unlocking items
    i ! < 1
    /* End of Warehouse Thread */
    /* CONTEXT SWITCH */
    Thread == Manager
        locking items (lock available)
          adding to itemes
        unlock items
        sleeping 500
        printing "Manager adding to items"
      j = 2
        locking items
          adding to itemes
        unlock items
        sleeping 500
        printing "Manager adding to items"
      j = 3
        locking items
          adding to itemes
        unlock items
        sleeping 500
        printing "Manager adding to items"
      j = 4
        locking items
          adding to itemes
        unlock items
        sleeping 500
        printing "Manager adding to items"
      j ! < 5
      printing "Manager finished with warehouse..."
    i ! < 1
    /* End of Manager Thread */So the theory an practice are the same - you can not access the items object when it is locked by another thread. The problem is that your test does not demonstrate when locks are held and released - some of the output you expect to be protected is not and so you mis-interpret the code.

  • General question about iTunes Match and multiple libraries

    Hello to everyone,
    I have a general question about the iTunes Match service, which is available since yesterday in my country (Italy). Currently my library situation is the following:
    Computer A (desktop, Windows 7): "big" iTunes library (about 20 GB), at the moment not associated with my Apple ID
    Computer B (MacBook Air 2011): "small" iTunes library (about 5 GB), associated with my Apple ID
    At the moment, both my iOS devices (iPhone 4 and iPad 2) are synchronized with the smaller library on the MacBook Air.
    Question is as follows: should I subscribe to iTunes Match, would it be possible to upload the "big" library (provided I associate it with my Apple ID) to iCloud while keeping my devices synchronized with the "small" one?
    Ideally, at the end of the day, the situation should be the following: both iOS devices with music from the small library + possibility of downloading songs from iCloud (coming from the big one). Is this possible?
    Maybe the question sounds stupid, but I want to be sure about this before paying for the service.
    Thanks a lot.

    Yes, you could also associate your larger library with iTunes match if you associated your Apple ID with it. However any purchases in the library made from another Apple ID will not be matched with iTunes much.
    If both libraries are part of iTunes match, then all your devices will see all of the content from both libraries, which content you choose to have on those devices and which you have accessible via iTunes match is entirely up to you.

  • The question about portlet customization and synchronization

    I have a question about portlet customization and synchronization.
    When I call
    NameValuePersonalizationObject data = (NameValuePersonalizationObject) PortletRendererUtil.getEditData(portletRenderRequest);
    portletRenderRequest.setPortletTitle(str);
    portletRenderRequest.putString(aKey, aValue);
    PortletRendererUtil.submitEditData(portletRenderRequest, data);
    Should I make any synchronization myself (use "synchronized" blocks or something else) or this procedure is made thread-safe on the level of the Portal API?

    HI Dimitry,
    I dont think you have to synchronize the block. i guess the code is synchronized internally.
    regards,
    Harsha

  • ####a question about jdbc driver

    A question about jdbc driver: for Oracle JDBC drivers which will not allow O/R
    tools to access columns over 4 kb. This affects some of the functionality of my
    application.A workaround is to use the my JDBC driver that acts as a wrapper to
    ensure that columns over 4 kb read and persist properly. my JDBC driver determines
    which actual driver to load based on the connection URL. If you pass in a URL
    that contains the string jdbc:oracle:thin, it will know to load oracle.jdbc.driver.OracleDriver.
    If the URL contains the string jdbc:db2, it will know to load COM.ibm.db2.jdbc.net.DB2Driver,
    and so on.
    now i have set CLASSPATH for my jdbc wapper,when I Creating and Configuring a
    JDBC Connection Pool,i have to input my driver name such com.lawrence.driver.....then
    i did,all
    is well,then i restart my WLS,when load config.xml,some errors such as "No registered
    driver accept URL:jdbc:oracle:thin:@localhost:1521:lawrence",if i set driver name
    is oracle.jdbc.driver.OracleDriver,all is good,no any errors.
    I find some questions like:
    1.for WLS8.1 ,it is only find some registed driver?
    2.why it cannot load my driver wapper when it is loading jdbc Connection Pool,but
    when the WLS start is finished, i Creating and Configuring a JDBC Connection Pool
    then it is right?

    my JDBC driver like this:
    public class myDriver implements Driver {
         public static String DB2_DRIVER = "COM.ibm.db2.jdbc.net.DB2Driver";
         public static String DB2_URL = "jdbc:db2:";
         public static String HYPERSONIC_DRIVER = "org.hsqldb.jdbcDriver";
         public static String HYPERSONIC_URL = "jdbc:hsqldb:";
         public static String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
         public static String MYSQL_URL = "jdbc:mysql:";
         public static String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver";
         public static String ORACLE_URL = "jdbc:oracle:";
         public static String POSTGRESQL_DRIVER = "org.postgresql.Driver";
         public static String POSTGRESQL_URL = "jdbc:postgresql:";
         public static String SQLSERVER_DRIVER =
              "com.microsoft.jdbc.sqlserver.SQLServerDriver";
         public static String SQLSERVER_URL = "jdbc:microsoft:";
         public boolean acceptsURL(String url) throws SQLException {
              return true;
         public synchronized Connection connect(String url, Properties props)
              throws SQLException {
              if (_driver == null) {
                   Class driverClass = null;
                   try {
                        if (url.startsWith(DB2_URL)) {
                             driverClass = Class.forName(DB2_DRIVER);
                        else if (url.startsWith(HYPERSONIC_URL)) {
                             driverClass = Class.forName(HYPERSONIC_DRIVER);
                        else if (url.startsWith(MYSQL_URL)) {
                             driverClass = Class.forName(MYSQL_DRIVER);
                        else if (url.startsWith(ORACLE_URL)) {
                             driverClass = Class.forName(ORACLE_DRIVER);
                        else if (url.startsWith(POSTGRESQL_URL)) {
                             driverClass = Class.forName(POSTGRESQL_DRIVER);
                        else if (url.startsWith(SQLSERVER_URL)) {
                             driverClass = Class.forName(SQLSERVER_DRIVER);
                        _driver = (Driver)driverClass.newInstance();
                   catch (Exception e) {
                        throw new SQLException(e.getMessage());
              Connection con = _driver.connect(url, props);
              return new myConnection(con);
         public int getMajorVersion() {
              return _driver.getMajorVersion();
         public int getMinorVersion() {
              return _driver.getMinorVersion();
         public DriverPropertyInfo[] getPropertyInfo(String url, Properties props)
              throws SQLException {
              return _driver.getPropertyInfo(url, props);
         public boolean jdbcCompliant() {
              return _driver.jdbcCompliant();
         private Driver _driver;

  • N00b question about the ABS

    Hey, I am new to Arch and I'm about to install it on my machine (used it a bit in a virtual machine) and I have a small nooby question about the ABS.
    According to the wiki: https://wiki.archlinux.org/index.php/Arch_Build_System
    "Running abs as root creates the ABS tree by synchronizing with the Arch Linux server."
    Does this mean that the ABS tree (not the package) is always downloaded from the official Arch Linux servers, never from any of the mirrors?

    jomasti wrote:
    ANOKNUSA wrote:makepkg is part of the abs package.
    You might be confusing that with makeworld. makepkg is included with pacman.
    Anyway, gregor, you are confusing the AUR with ABS. Although, what you are saying is still possible via the source files when looking up a package on https://www.archlinux.org/packages/. But with both, using a program or using the respective page is a personal choice.
    Yup, you're right.  My mistake.

  • Question on synchronized

    Hello:
    Suppose I have this code:
    class BigClass
        class MyThread extends Thread
              @Override public void run()
                   inst.DoSomethingLocal();
                   inst.DoSomethingGlobal();
        int globalvar=0;
        public int /*synchronized*/ DoSomethingLocal()
            int localVar1=0;
            int localVar2=0;
            return localVar1+localVar2;
        public int synchronized DoSomethingGlobal()
            int localVar1=0;
            int localVar2=0;
            globalvar++;
            return localVar1+localVar2;
        public void init()
           MyThread  t1=new MyThread();  
           MyThread  t2= new MyThread();
           t1.start();
           t2.start();
    }My question is: if I call DoSomethingGlobal() from both threads, I need synchronized keyword, since I would be accessing globalvar from two threads. But what would happen to local variables of DoSomethingLocal(), if I do not use synchronized keyword... would local data get corrupted? should I use synchronized for this also?
    Thanks!

    DynamicBasics wrote:
    jverd wrote:
    You're just creating a task to be run in a thread.In this given case each thread would have its own copy of globalvar, or would it be shared resource?In your code as presented, the two Threads are both members of a single BigClass . Since globalvar is part of BigClass , not MyThread, those Thread objects share the same variable. (I think so anyway. I'm running on very little sleep, so my brain's a little foggy. It's trivial to test though.)
    Is it not that two copies of the globalvar would be created one for each object? One for each BigClass object, of which you have only one in this context.
    Is it that this behaviour is exhibited only when Runnable is implemented and by not extending Thread class as depicted in the example. Any thoughts?No, my advice to implement Runnable has nothing to do with your questions about syncing. It's simply general good advice. I doubt you'll ever have a valid reason to extend Thread.

  • A question about Enumeration()

    i am a beginner in java,resently i met a question about Enumeration(),and i hope someone can help me.
    my question is that in the package of java.util there is an interface called Enumeration and there are two method hasMoreElements()��nextElemen() in it.
    but in general we do not realize them before we use them.for example:
    first we defined a new class Vector
    Vector myVector = new Vector();
    then when after we add some objects to it,we can do like this:
    Enumeration e = myVectior.elements();
    e.nextElemen();
    i want to know where the method nextElemen is realized? incording to java's grammar,it is impossible to be realized in Enumeration for it is an interface,but
    both class Vector and the my own class do not realize it too.so i am confused.

    The class that implements the Enumeration returned by elements is hidden in the Vector class implementation. In fact, the class is anonymous. Here's the code from java.util.Vector (JDK 1.4).
       public Enumeration elements() {
            return new Enumeration() {
                int count = 0;
                public boolean hasMoreElements() {
                    return count < elementCount;
                public Object nextElement() {
                    synchronized (Vector.this) {
                        if (count < elementCount) {
                            return elementData[count++];
                    throw new NoSuchElementException("Vector Enumeration");
        }

  • Question about singleton design

    Hi all
    i have a question about singleton design. as i understood it correctly, this pattern garantees us a single instance of a class at any time. in a environment of concurrent access(multiple user access at the same time) , does this single instance put a constraint on concurrency(singleton == synchronization)? i have developed a service object that reads in properties and constructs some other objects. the reason i made it singleton is that i only want this service object to load the properties once. and when it is called to create other objects, it always has one copy of the propertis. making this service singleton, will it limit the threads to access it and construct other objects? thanks for your help.

    If there's no write access to the HashMap, then
    you're thread safe.You were probably typing at the same time as the previous post, which explicitly says there IS write access to the HashMap.
    I don't know what it is, but people seem to have this magical view of concepts. Singleton is just what it is. It doesn't have a magical aura that causes other things to behave differently. A singleton is just Java code that can have thread safety problems just like any other Java code. So to the OP: forget about the fact that this is a singleton. That's irrelevant. Ask if a method needs to be synchronized.
    (And yes, a method that tests if a variable is null and assigns an object to it if it isn't null does need to be synchronized if it's going to have multiple threads accessing it.)

  • Questions about your new HP Products? HP Expert Day: January 14th, 2015

    Thank you for coming to Expert Day! The event has now concluded.
    To find out about future events, please visit this page.
    On behalf of the Experts, I would like to thank you for coming to the Forum to connect with us.  We hope you will return to the boards to share your experiences, both good and bad.
     We will be holding more of these Expert Days on different topics in the months to come.  We hope to see you then!
     If you still have questions to ask, feel free to post them on the Forum – we always have experts online to help you out.
    So, what is HP Expert Day?
    Expert Day is an online event when HP employees join our Support Forums to answer questions about your HP products. And it’s FREE.
    Ok, how do I get started?
    It’s easy. Come out to the HP Support Forums, post your question, and wait for a response! We’ll have experts online covering our Notebook boards, Desktop boards, Tablet boards, and Printer and all-in-one boards.
    We’ll also be covering the commercial products on the HP Enterprise Business Community. We’ll have experts online covering select boards on the Printing and Digital Imaging and Desktops and Workstations categories.
    What if I need more information?
    For more information and a complete schedule of previous events, check out this post on the forums.
    Is Expert Day an English-only event?
    No. This time we’ll have experts and volunteers online across the globe, answering questions on the English, Simplified Chinese, and Korean forums. Here’s the information:
    Enterprise Business Forum: January 14th 7:00am to 12:00pm and 6:00pm to 11:00pm Pacific Time
    Korean Forum: January 15th 10am to 6pm Korea Time
    Simplified Chinese Forum: January 15th 10am to 6pm China Time
    Looking forward to seeing you on January 14th!
    I am an HP employee.

    My HP, purchased in June 2012, died on Saturday.  I was working in recently installed Photoshop, walked away from my computer to answer the phone and when I came back the screen was blank.  When I turned it on, I got a Windows Error Recovery message.  The computer was locked and wouldn't let me move the arrow keys up or down and hitting f8 didn't do anything. 
    I'm not happy with HP.  Any suggestions?

Maybe you are looking for

  • TS3989 How to Order Photos in Photo Stream?

    Dear all, I would like to share my photos with my Apple TV and when I place images into my Album  I reorder those photos, however, when I upload to Photo Stream the photos pull from the original file name and order accourding to those names. Can we c

  • Should I Download Driver

    I have a HP Envy 15 Notebook PC with a  I7-4510U processor and a Nvidia GeForce 850M with 4GB memory and 1920 by 1080 touchscreen.  I see that Intel has come out with a new 64 bit driver https://downloadcenter.intel.com/Detail_Desc.aspx?​agr=Y&DwnldI

  • Macbook & netgear router

    Hi guys, I have a Macbook with AirPort Extreme (Firmware Version 1.1.9.3) and my flat has a wireless internet connection with Netgear DG834G. For the past few months I have been expriencing a very strange thing. My macbook connects with no problem to

  • Why itunes is automatic changing my genre to chinese when I play my songs?

    What is happening to my itunes? Every time I play a song the language of my genre just automatic change to chinese without infrom me anything. I've organized all the songs by the genres and also use genres to creat playlists for my ipod, but now they

  • Adobe Flash installs but can't use.

    Am using Windows 7 Pro and IE 9.  When I download it says Download Install Finish.  When I go to your website it does not show my OS or that Adobe Flash was installed.  However my Rebo Uninstaller Pro shows was installed and can be unintalled. Active