- 浏览: 1380862 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (346)
- linux (10)
- hbase (50)
- hadoop (23)
- java (52)
- java multi-thread (13)
- Oracle小记 (41)
- 机器学习 (12)
- 数据结构 (10)
- hadoop hive (16)
- java io (4)
- jms (1)
- web css (1)
- kafka (19)
- xml (2)
- j2ee (1)
- spring (6)
- ibatis (2)
- mysql (3)
- ext (3)
- lucene (3)
- hadoop pig (3)
- java nio (3)
- twemproxy (1)
- antlr (2)
- maven (6)
- mina (1)
- 列数据库 (1)
- oozie (2)
- mongodb (0)
- 报错 (0)
- jetty (1)
- neo4j (1)
- zookeeper (2)
- 数据挖掘 (3)
- jvm (1)
- 数据仓库 (4)
- shell (3)
- mahout (1)
- python (9)
- yarn (3)
- storm (6)
- scala (2)
- spark (5)
- tachyon (1)
最新评论
-
guokaiwhu:
赞啊!今晚遇到相同的问题,正追根溯源,就找到了博主!
hbase 报错gc wal.FSHLog: Error while AsyncSyncer sync, request close of hlog YouAr -
喁喁不止:
很清楚,有帮助。
hive常用函数 -
dsxwjhf:
Good job !!
kafka获得最新partition offset -
Locker.Xai:
参考了
freemaker教程 -
maoweiwer:
为啥EPHEMERAL_SEQUENTIAL类型的节点并没有自 ...
zookeeper 入门讲解实例 转
根据 Java API, 所谓 shutdown hook 就是已经初始化但尚未开始执行的线程对象。在
Runtime 注册后,如果 jvm 要停止前,这些 shutdown hook 便开始执行。
有什么用呢?就是在你的程序结束前,执行一些清理工作,尤其是没有用户界面的程序。
很明显,这些 shutdown hook 都是些线程对象,因此,你的清理工作要写在 run() 里。
根据 Java API,你的清理工作不能太重了,要尽快结束。但仍然可以对数据库进行操作。
package dirk.runtime; public class ShutDownHook implements Runnable { public ShutDownHook() { // register a shutdown hook for this class. // a shutdown hook is an initialzed but not started thread, which will get up and run // when the JVM is about to exit. this is used for short clean up tasks. Runtime.getRuntime().addShutdownHook(new Thread(this)); System.out.println(">>> shutdown hook registered"); } // this method will be executed of course, since it's a Runnable. // tasks should not be light and short, accessing database is alright though. public void run() { System.out.println("/n>>> About to execute: " + ShutDownHook.class.getName() + ".run() to clean up before JVM exits."); this.cleanUp(); System.out.println(">>> Finished execution: " + ShutDownHook.class.getName() + ".run()"); } // (-: a very simple task to execute void cleanUp() { for(int i=0; i < 7; i++ ) { System.out.println(i); } } /** * there're couple of cases that JVM will exit, according to the Java api doc. * typically: * 1. method called: System.exit(int) * 2. ctrl-C pressed on the console. * 3. the last non-daemon thread exits. * 4. user logoff or system shutdown. * @param args */ public static void main(String[] args) { new ShutDownHook(); System.out.println(">>> Sleeping for 5 seconds, try ctrl-C now if you like."); try { System.out.println("jvm run run run"); Thread.sleep(5000); // (-: give u the time to try ctrl-C System.out.println("jvm prepare to shutDown"); } catch (InterruptedException ie) { ie.printStackTrace(); } System.out.println(">>> Slept for 10 seconds and the main thread exited."); } }
发表评论
-
java内存使用查看 转
2015-10-29 14:51 824转:http://mxsfengg.iteye.com ... -
Java线上应用故障排查之二:高内存占用
2015-08-17 16:28 0搞Java开发的,经常会碰到下面两种异常: 1、java. ... -
java filechannel
2015-08-14 15:42 1003Java NIO中的FileChannel是一个连接到文件 ... -
Java线上应用故障排查之一:高CPU占用
2015-08-06 13:58 6116转http://blog.csdn.net/blade20 ... -
java注释
2015-04-10 15:49 0Java注解是附加在代码中的一些元信息,用于一些工具在编译、 ... -
转jvm
2015-03-24 14:13 1636一、回顾JVM内存分配 ... -
java 域名转换
2014-12-22 11:05 733import java.net.InetAddres ... -
freemaker教程
2014-10-13 11:56 1900新换了工作,与想象差距也太大了 最近沦落到做报表了,我就 ... -
protocal buffers入门实例
2014-09-22 21:08 1601hadoop yarn中新的系列化protocol buf ... -
正则小计
2014-09-18 20:47 0&site=(.*?)&可以匹配site的值 ... -
在HBase中应用MemStore-Local Allocation Buffers解决Full GC问题
2014-06-13 23:05 1539译者注:上个月 ... -
java ipc 实例
2014-05-21 22:59 4830java ipc实例,仿照hadoop ipc写的实例 1 ... -
java worker thread模式
2014-03-25 22:46 1930转两个帖子 一个java wo ... -
bloom filter
2014-03-09 19:41 1919看到hadoop join和hbase都有bloo ... -
java reference
2014-03-09 17:49 684转 http://www.iteye.com/to ... -
annotation实例
2014-02-11 22:04 1097加载指定目录的所有class,通过注释区分实体类 p ... -
java获取子类 转
2014-02-11 16:58 3079获取子类 package com.tools; ... -
动态代理
2013-08-14 20:38 1038动态代理,转:http://langyu.iteye. ... -
java byte inputstream and outputstream
2013-02-18 11:47 0转http://blog.csdn.net/rcoder ... -
JVM同步浅析
2013-01-11 11:38 1605堆 (所有类的实例或 ...
相关推荐
JRE 1.4.2 JRE(Java Runtime Environment,Java运行环境),运行JAVA程序所必须的环境的集合,包含JVM标准实现及Java核心类库。
JRE(Java Runtime Environment)——windows Java运行环境 64bit
JRE1.8.0(Java Runtime Environment)——Java运行环境32bit
Java Runtime Environment-6.0.26.exe
Java Runtime Environment 1.6.0.7 (32-bit
java runtime environment 1.8.0_45 64bit.rar
Java Runtime For MacOS X 10.7
java runtime environment 1.8.0_45 64bit jre1.8.0_45 64bit jre-8u261
Installation notes for the J2SE Runtime Environment 5.0 (JRE), including system requirements and installation instructions, are available for the following platforms. Platform 32-bit Installation 64...
jre(Java Runtime Environment),Java运行环境64位安装包
毕业时的外文翻译原文 A Race-Aware Java Runtime
jre(Java Runtime Environment),Java运行环境32位安装包
java runtime environment(JRE)安装 2020-11-4 一、搭建环境 1.1 安装Keil 5 官网下载:http://www2.keil.com/mdk5/ 百度网盘:https://pan.baidu.com/s/18t_ta0WWX_f1KCKXfgj_Zw 提取码:gx3r 1.2 安装JRE 由于...
Java Runtime Environment-6.0.450
NULL 博文链接:https://dingherry.iteye.com/blog/1545972
Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序 Runtime类Java SE程序...
java 环境
ArcGIS Runtime SDK for Java 100.12.0 的...如需在生产环境中使用ArcGIS Runtime SDK for Java,请联系ESRI公司获得授权,现在也有国产替代产品GeoScne Runtime SDK for Java,可以联系易智瑞公司获得相关资源和授权。
Java Runtime Environment,Java运行环境64位安装包,官网下载。 Java SE Runtime Environment 8 Downloads Do you want to run Java™ programs, or do you want to develop Java programs? If you want to run ...
Java SE Runtime Environment(运行时环境)包含了运行以 Java 编程语言编写的程序所必需的 Java 虚拟机、运行时类库和 Java 应用程序启动器。 Java 平台的安全性 一个由角色提供的安全信息的描述。适用于开发人员...