ThreadPoolManager + Calendar

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Sikken
Posts: 53
Joined: Sat Sep 05, 2009 10:03 pm

ThreadPoolManager + Calendar

Post by Sikken »

so i want to fun 'TestManager' every hour, on the hour. how will i go about doing that?

Code: Select all

 private final int SECOND = 60000;private final int MINUTE = 60*SECOND;private final int HOUR = 60*MINUTE;private final int DAY = 24*HOUR; 

Code: Select all

 Calendar calendar = Calendar.getInstance();calendar.add(Calendar.HOUR,calendar.get(Calendar.HOUR)+1);calendar.set(Calendar.MINUTE,0);calendar.set(Calendar.SECOND,0);calendar.set(Calendar.MILLISECOND,0);SWIMMER = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TestManager(),calendar.getTimeInMillis()-System.currentTimeMillis(),1*HOUR); 
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: ThreadPoolManager + Calendar

Post by tukune »

:evil: private final int SECOND = 60000;
:D private final long SECOND = 1000L;

:evil: calendar.add(Calendar.HOUR,calendar.get(Calendar.HOUR)+1);
:D calendar.add(Calendar.HOUR, 1);

:D SWIMMER = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TestManager(),calendar.getTimeInMillis()-System.currentTimeMillis(), 3600_000L);
User avatar
Sikken
Posts: 53
Joined: Sat Sep 05, 2009 10:03 pm

Re: ThreadPoolManager + Calendar

Post by Sikken »

Code: Select all

 compile:    [javac] Compiling 1278 source files to J:\L2Server\Sources\aCis_gameserver\build\classes    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5    [javac] J:\L2Server\Sources\gameserver\java\net\sf\l2j\gameserver\events\AutoEventManager.java:73: error: underscores in literals are not supported in -source 1.5    [javac]         SWIMMER = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoEvent(),calendar.getTimeInMillis()-System.currentTimeMillis(),3600_000L);    [javac]                                                                                                                                                    ^    [javac]   (use -source 7 or higher to enable underscores in literals)    [javac] 1 error    [javac] 1 warning 
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: ThreadPoolManager + Calendar

Post by jurchiks »

duh... remove the underscore from "3600_000L"
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
Stake
Posts: 383
Joined: Sun Mar 23, 2008 9:33 pm
Location: Hungary
Contact:

Re: ThreadPoolManager + Calendar

Post by Stake »

Anyway, there is no either need for the "L" literal, only when you give a value that is bigger than 2^31-1, but you will never write that big constant number.
Image
Image
Post Reply