Skip to content

Commit

Permalink
Encourage named threads for easier debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
maiksd authored and darkv committed Apr 25, 2016
1 parent f04e5d2 commit 3f81ea6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public abstract class ERXShutdownHook extends Thread {

public static void initERXShutdownHook() {
System.out.println( "WILL ADD SHUTDOWNHOOK" );
Runtime.getRuntime().addShutdownHook( new Thread() {
Runtime.getRuntime().addShutdownHook( new Thread( "shutdown_complete_message_writer" ) {
@Override
public void run() {
try {
Expand Down Expand Up @@ -90,7 +90,8 @@ public static void useMe() {
}

/**
* Construct a new nameless shutdown hook and register it.
* Construct a new nameless shutdown hook and register it. It is recommended to use named hooks wherever
* possible for easier debugging.
*/
public ERXShutdownHook() {
Runtime.getRuntime().addShutdownHook( this );
Expand All @@ -102,8 +103,10 @@ public ERXShutdownHook() {
* @param hookName hook name
*/
public ERXShutdownHook( String hookName ) {
this();
super( hookName );
name = hookName;
Runtime.getRuntime().addShutdownHook( this );
ALL_HOOKS.add( this );
}

@Override
Expand Down

0 comments on commit 3f81ea6

Please sign in to comment.