Page 1 of 1

ThreadPoolManager + Calendar

Posted: Tue Nov 08, 2011 3:59 pm
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); 

Re: ThreadPoolManager + Calendar

Posted: Tue Nov 08, 2011 5:01 pm
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);

Re: ThreadPoolManager + Calendar

Posted: Tue Nov 08, 2011 5:24 pm
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 

Re: ThreadPoolManager + Calendar

Posted: Tue Nov 08, 2011 6:45 pm
by jurchiks
duh... remove the underscore from "3600_000L"

Re: ThreadPoolManager + Calendar

Posted: Wed Nov 09, 2011 6:38 pm
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.