Thread: Having something start...

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Having something start... 
    Registered Member
    Markian's Avatar
    Join Date
    Apr 2009
    Posts
    614
    Thanks given
    17
    Thanks received
    26
    Rep Power
    373
    How can I make something start every 60 seconds, like an event manager, except without the eventmanager and without using process.
    Reply With Quote  
     

  2. #2  
    :doge:

    Join Date
    Jan 2009
    Posts
    3,759
    Thanks given
    221
    Thanks received
    815
    Rep Power
    2088
    a thread?
    Reply With Quote  
     

  3. #3  
    0x2B | ~0x2B


    Impulser's Avatar
    Join Date
    Jul 2006
    Posts
    1,305
    Thanks given
    389
    Thanks received
    335
    Rep Power
    2751
    Suffin liek dis:
    Code:
    for(int i = 1; i =< 60; i++, Thread.Sleep(1000))
    {
        if(i == 60)
        {
            // Your Code Here
        }
    }
    Reply With Quote  
     

  4. #4  
    Registered Member
    Markian's Avatar
    Join Date
    Apr 2009
    Posts
    614
    Thanks given
    17
    Thanks received
    26
    Rep Power
    373
    How can I make this re run every 60 seconds with the whole server:


    public void run() {
    long lastTicks = System.currentTimeMillis();
    long totalTimeSpentProcessing = 0;
    int cycle = 0;
    while (!server.shutdownServer) {

    /*Save everyone online*/
    saveServer(false);
    }
    Reply With Quote  
     

  5. #5  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,142
    Thanks given
    255
    Thanks received
    1,239
    Rep Power
    3584
    new Thread(aRunnableClass).start();

    public void run() {


    Thread.sleep(60000);
    }

    Or you could use the java.util.concurrency apis.


    Edit: Just use events or process, any type of thing you use, they will all be processed.

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  6. #6  
    :doge:

    Join Date
    Jan 2009
    Posts
    3,759
    Thanks given
    221
    Thanks received
    815
    Rep Power
    2088
    Code:
    		Thread example = new Thread(new Runnable() {
    			public void run() {
    				
    			}
    		});
    		example.start();
    Reply With Quote  
     

  7. #7  
    Registered Member
    Markian's Avatar
    Join Date
    Apr 2009
    Posts
    614
    Thanks given
    17
    Thanks received
    26
    Rep Power
    373
    Quote Originally Posted by 'Mystic Flow View Post
    new Thread(aRunnableClass).start();

    public void run() {


    Thread.sleep(60000);
    }

    Or you could use the java.util.concurrency apis.


    Edit: Just use events or process, any type of thing you use, they will all be processed.

    Yeah, but I can't put the garbage collector in process system.gc.
    Reply With Quote  
     

  8. #8  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,142
    Thanks given
    255
    Thanks received
    1,239
    Rep Power
    3584
    Quote Originally Posted by Markian View Post
    Yeah, but I can't put the garbage collector in process system.gc.
    public void process() {
    System.gc();
    }

    Is that so hard?

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  9. #9  
    Registered Member
    Markian's Avatar
    Join Date
    Apr 2009
    Posts
    614
    Thanks given
    17
    Thanks received
    26
    Rep Power
    373
    Quote Originally Posted by 'Mystic Flow View Post
    public void process() {
    System.gc();
    }

    Is that so hard?
    Then system gc would loop every 500 milliseconds or so which would cause great lagg. I need it to do it every 60 seconds and not just for 1 person, for everyone so something like this wouldnt work in process

    Code:
    		if (System.currentTimeMillis() - restart > 60000){
    System.gc();
    			restart = System.currentTimeMillis();
    		}
    Reply With Quote  
     

  10. #10  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,142
    Thanks given
    255
    Thanks received
    1,239
    Rep Power
    3584
    Honestly, why would you want to use System.gc();, if your server is well programmed and very stable then you wouldn't need to use System.gc();, the garbage collector should only be used after start up.


    edit: Why don't you just put that code you got up there in the process -_-

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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