Jump to content

Some Java (New Object) Explanation.


Recommended Posts

Ok i have a question that bother me 5 seconds now

 

Let's say we make a class and this class just do something 


public class Spammer
    final L2PcInstance _player;
int index = 0;
 
    Spammer(L2PcInstance player)
{
 _player = player;
start();
}
 
    public void start()
{
ThreadPoolManager.scheduleFixedRate(new Runnable()
{
@Override
public void Run()
{
  if (index == 5)
  {
_player.sendMessage("hi");
index++;
  }
  else
  _threadpool.cancel(true);
}
 
}, 1000, 1000);
}
​}

The code is really to explain you.

 

So let's say we do   new Spammer(player); 

this will start the threadpool and after 6 times it will stop send player a message. 

 

But what java do afterwards? What happen to this class created as new object ? It get fucked up garbage collector since its not doing anything ? 

 

I did a code that basically create a new object for vote but i was wondering after the time expire and give reward or no give reward what happen to this class? 

 

Thanks

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock