Jump to content

Question

Posted

+    public static PvPRewards getInstance()
+    {
+        PvPRewards _instance = null;
+        if (_instance == null)
+        {
+            _instance = new PvPRewards();
+        }
+        
+        return _instance;
+    }

 

 

Fanky, go find another career, xdem was near me at the net cafe when I told him to see that you should see his reaction rofl, his words best singleton EU

9 answers to this question

Recommended Posts

  • 0
Posted (edited)

What is the problem? That is the new singleton design :P

PvPRewards _instance = null;

must be out, otherwise it recreates the instance over and over. Basically said there is no permanent instance.

 

But this writing style is possible, it was the writing style on L2J IL for example. Correct version should be :

private static PvPRewards _instance = null;

public static PvPRewards getInstance()
{
    if (_instance == null)
        _instance = new PvPRewards();
        
    return _instance;
}

More informations about the different possibilities, thread-safe and not :

http://stackoverflow.com/questions/11165852/java-singleton-and-synchronization

 

For the trivia, aCis still has a leftover of that era via Announcements.java. Need to rework it.

Edited by Tryskell
  • 0
Posted
PvPRewards _instance = null;

must be out, otherwise it recreates the instance over and over. Basically said there is no permanent instance.

 

But this writing style is possible, it was the writing style on L2J IL for example. Correct version should be :

private static PvPRewards _instance = null;

public static PvPRewards getInstance()
{
    if (_instance == null)
        _instance = new PvPRewards();
        
    return _instance;
}

More informations about the different possibilities, thread-safe and not :

http://stackoverflow.com/questions/11165852/java-singleton-and-synchronization

 

For the trivia, aCis still has a leftover of that era via Announcements.java. Need to rework it.

 

Well, there was a little bit of sarcasm in my comment ^_^

  • 0
Posted

+    public static PvPRewards getInstance()

+    {

+        PvPRewards _instance = null;

+        if (_instance == null)

+        {

+            _instance = new PvPRewards();

+        }

+        

+        return _instance;

+    }

 

 

Fanky, go find another career, xdem was near me at the net cafe when I told him to see that you should see his reaction rofl, his words best singleton EU

So xdem is at net cafe ;D ? no internet at home :3 ?

  • 0
Posted

Well, there was a little bit of sarcasm in my comment ^_^

 

I knew, but at least I give answers for people. Because you know... knowledge has to be shared. Not simply mocking over people when they do mistakes. It can be useful for the initial guy who made the error, as for any people.

  • 0
Posted

I knew, but at least I give answers for people. Because you know... knowledge has to be shared. Not simply mocking over people when they do mistakes. It can be useful for the initial guy who made the error, as for any people.

I highly share that! :)

  • 0
Posted

I knew, but at least I give answers for people. Because you know... knowledge has to be shared. Not simply mocking over people when they do mistakes. It can be useful for the initial guy who made the error, as for any people.

 

+1

 

Locked!

Guest
This topic is now closed to further replies.


×
×
  • Create New...