- 浏览: 80815 次
文章分类
最新评论
-
bailangfei3344:
自我介绍 -
regionwar:
你好,转化为人为:1、不该加锁的不要加锁:局部变量,单线程占用 ...
关于java锁机制的优化 -
danni505:
希望能交流:
msn:danni-505#hotmail.co ...
关于java锁机制的优化 -
ouspec:
收藏的东西不错。
TOP500 -
willpower:
The idea behind is e-sync IO do ...
Rethink the sync
Java shutdown hook guarantee that clean-up code is always run, regardless of how the user terminates the application.
Here is an example from Hadoop:
java 代码
- /**
- * A class to track the list of DFS clients, so that they can be closed
- * on exit.
- * @author Owen O'Malley
- */
- private static class ClientFinalizer extends Thread {
- private List clients = new ArrayList();
- public synchronized void addClient(DFSClient client) {
- clients.add(client);
- }
- public synchronized void run() {
- Iterator itr = clients.iterator();
- while (itr.hasNext()) {
- DFSClient client = (DFSClient) itr.next();
- if (client.running) {
- try {
- client.close();
- } catch (IOException ie) {
- System.err.println("Error closing client");
- ie.printStackTrace();
- }
- }
- }
- }
- }
- // add a cleanup thread
- private static ClientFinalizer clientFinalizer = new ClientFinalizer();
- static {
- Runtime.getRuntime().addShutdownHook(clientFinalizer);
- }
Elegant and useful!!!
发表评论
-
字符编码笔记:ASCII,Unicode和UTF-8 (引用)
2009-01-07 10:39 875字符编码笔记:ASCII,Unicode和UTF-8 阮一峰 ... -
How to set up a simple LRU cache using LinkedHash
2008-11-03 18:05 1231How to set up a simple LRU cach ... -
Scalability?
2008-10-07 14:07 760严格上讲,scalability还没有正式定义, 甚至有人觉得 ... -
Cray Reminiscences
2007-08-29 15:54 744Kirk Pepperdine's attendence of ... -
lock-free
2007-06-18 22:06 9501. http://www.ibm.com/developer ... -
解决java.lang.OutOfMemoryError: PermGen space(转帖)
2007-06-05 18:07 3105解决方案就是:在启动服务器时加上指定PermGen区域的内存大 ... -
Performance...
2007-06-05 15:11 913« I used to work for... | Mai ... -
数据仓库
2007-04-18 10:38 1051... -
Expressions Transform
2007-04-13 11:13 1325Expressions, Conversion and Eva ... -
Java performance tunning
2007-04-03 11:37 882http://www.javaperformancetunin ... -
Running IE from command line
2007-04-03 10:58 1058Here's a simple way you can ru ... -
Unicode and UTF8
2007-04-03 10:27 871What is Unicode? Unicode provid ... -
Daemon Thread Notes
2007-04-03 09:16 26111. 只要程式中的non-Daemon thread都結束了. ... -
How to know the main class of a jar file?
2007-04-02 15:18 965Easy. Here is an implementation ... -
The best chinese BAT tutorial(from www.boofee.net/bigfee/)
2007-03-27 11:58 1269如何创建批处理文件? 不要听了批处理文件就感到很神气 ... -
Basics - Binary search
2007-03-26 15:53 910java 代码 public class Bin ... -
MergeSort
2007-03-23 17:26 761MergeSort is a sample solutio ... -
Graph data structure
2007-03-23 12:04 8281. adjacent matrix good for bor ... -
Functional Programming For The Rest of Us
2007-03-23 10:39 900I like connect beautiful artic ... -
Functional Programming For The Rest of Us
2007-03-23 10:24 780I like connect beautiful artic ...
相关推荐
But if code isn’t clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn’t have to ...
Visual Studio Code works with all major Java versions from various vendors up to 13. To help you get started quickly, we created a special Installer of Visual Studio Code for Java developers. The ...
Because App Engine supports common Java API standards, your code stays clean and portable. Get a hands-on introduction to App Engine's tools and features, using an example application Simulate App ...
This book will teach the concepts of test driven development in Java so you can build clean, maintainable and robust code About This Book Explore the most popular TDD tools and frameworks and become...
Write code that's clean, concise, and to the point: code that others will read with pleasure and reuse. Comparing your code to that of expert programmers is a great way to improve your coding skills. ...
压缩包中包含了checkstyle-profile.xml,cleanup-profile.xml,codetemplates.xml,formatter-profile.xml四个代码格式化的配置文件,只需要在eclipse->window->preferences->java->code style中import对应的xml即可...
清理:cleanup.xml 命名约定 Eclipse 项目名称约定 名称 评论 啊啊啊 pom 项目作为所有项目的父项目 aaa-common 通用代码:实用程序、常量、异常、... aaa-*-客户端 实体、服务接口 aaa-*-服务 EJB,服务实现 aaa-...
You must perform cleanup ......... 121 The termination condition ......... 121 How a garbage collector works .. 122 Member initialization ......... 125 Specifying initialization ............. 126 ...
Furthermore, the book walks you through setting up and using Maven with popular Java Integrated Development Environments (IDEs) so you can exploit Maven features to build standard Java applications....
Debug HTTP API calls to a back-end and between back-ends, Easy to use, clean UI, and short ramp-up time. Not a proxy, no network issues! Doesn't change the browser's configuration for the proxy. Can ...
Create a custom user tool to compile Java code, using the command line, from within UltraEdit Configure UltraEdit with javascript lint How to check your JavaScript source code for common mistakes ...
Exceptions to the Rules Existing Non-conformant Code Windows Code Important Note Displaying Hidden Details in this Guide link ▶This style guide contains many details that are initially hidden from ...
怎么跑要求Java 11 玛文码头工人脚步您只需要运行以下命令: mvn clean package // to generate the jardocker build .docker-compose up -d为了方便起见,还有一个名为build_and_start.sh的文件,该文件完全执行...
Fast Data Processing with Spark covers everything from setting up your Spark cluster in a variety of situations (stand-alone, EC2, and so on), to how to use the interactive shell to write distributed ...
It provides clean, straightforward examples that make learning easy, allowing you to pick up the concepts without fuss. It offers clear code descriptions and layout so that you can get your apps ...
Code cleanup and refactoring will take place under a separate commit. Note that there is still no support in the .NET bindings for the Presto-based Opera without using the remote server, nor is ...
:thumbs_up: 目前不接受与应用程序的体系结构和功能有关的外部PR。 :stop_sign: 列出热门/收视率最高的电影,显示预告片和评论的Android应用。 该应用程序展示了MVP模式,RxJava,Dagger 2和Bob Martin叔叔的...
Apktool will work fine without running these commands, this will just cleanup abandoned files unix - mkdir -p ~/.local/share; mv ~/apktool ~/.local/share windows - move %USERPROFILE%\apktool %...
Starting with version 3, i will be supporting cleanup/removal from many devices. The checking part of the app will always be free here but because of the time it took me to universally code the ...
1. Confirm a Clean Installation of a Basic Linux Kernel 38 2. Modify Your Kernel Configuration to Accommodate Android Drivers 38 3. Write Drivers 38 4. Burn Images to Flash 39 5. Boot the kernel and ...