java没有timer类_java.util.Timer类的使用

代码:

1、

timer5 = new Timer();

Calendar now=Calendar.getInstance();

now.set(Calendar.HOUR_OF_DAY,new Date().getHours());

now.set(Calendar.MINUTE, new Date().getMinutes());

now.set(Calendar.SECOND, new Date().getSeconds()+10);

now.set(Calendar.MILLISECOND, 0);

System.out.print("\n时间now为: "+now.toString()+" 毫秒数:"+now.getTimeInMillis());

Date operTime=new Date(now.getTimeInMillis());

System.out.println("\n预设初始执行时间为: "+operTime);

timer.schedule(task,operTime,1);

2、

private TimerTask task = new TimerTask() {

public void run() {

scoreCount();

System.gc();

}

};

在2、中不添加System.gc()时,tomcat会出现自动关闭的问题,同时产生了一个hs_err_pid12588.log文件,内容如下

#

# An unexpected error has been detected by Java Runtime Environment:

#

# java.lang.OutOfMemoryError: requested 32756 bytes for ChunkPool::allocate. Out of swap space?

#

# Internal Error (allocation.cpp:120), pid=12588, tid=9048

# Error: ChunkPool::allocate

#

# Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)

# If you would like to submit a bug report, please visit:

# http://java.sun.com/webapps/bugreport/crash.jsp

#

--------------- T H R E A D ---------------

Current thread (0x02308400): VMThread [stack: 0x48870000,0x488c0000] [id=9048]

Stack: [0x48870000,0x488c0000]

[error occurred during error reporting (printing stack bounds), id 0xc0000005]

VM_Operation (0x6967f574): DeoptimizeFrame, mode: safepoint, requested by thread 0x4ab02000

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )

0x4a788000 JavaThread "Thread-63821" daemon [_thread_in_native, id=8064, stack(0x7a900000,0x7a950000)]

0x5d569c00 JavaThread "Thread-63687" daemon [_thread_blocked, id=11108, stack(0x7de50000,0x7dea0000)]

0x5d5b4400 JavaThread "Thread-63686" daemon [_thread_in_native, id=9124, stack(0x7ddc0000,0x7de10000)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值