Skip to content

Commit

Permalink
v0.15-b8, tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tduva committed Jun 20, 2021
1 parent a5ba7d4 commit 576822e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/chatty/Chatty.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Chatty {
* by points. May contain a single "b" for beta versions, which are counted
* as older (so 0.8.7b4 is older than 0.8.7).
*/
public static final String VERSION = "0.15-b7"; // Remember changing the version in the help
public static final String VERSION = "0.15-b8"; // Remember changing the version in the help

/**
* Enable Version Checker (if you compile and distribute this yourself, you
Expand Down
2 changes: 1 addition & 1 deletion src/chatty/gui/components/help/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1><a name="top">Chatty (Version: 0.15-b7)</a></h1>
<h1><a name="top">Chatty (Version: 0.15-b8)</a></h1>
<table>
<tr>
<td valign="top">
Expand Down
15 changes: 11 additions & 4 deletions src/chatty/util/LogUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ public void run() {
}

private static final AtomicInteger EDT_LOCK_STATE = new AtomicInteger();
private static final ElapsedTime EDT_LOCK_LOG = new ElapsedTime();
private static final ElapsedTime EDT_LOCK_LAST_LOGGED = new ElapsedTime();

/**
* Tries to set a value through the EDT regularly in order to detect when it
* may have locked up (and logs the current thread info if so).
*/
public static void startEdtLockDetection() {
Thread thread = new Thread(() -> {
int state = 0;
Expand All @@ -106,22 +110,25 @@ public static void startEdtLockDetection() {
});
Thread.sleep(1000);
// Should be set by now, otherwise the EDT is really slow
if (EDT_LOCK_STATE.get() != state && EDT_LOCK_LOG.secondsElapsed(600)) {
EDT_LOCK_LOG.set();
if (EDT_LOCK_STATE.get() != state && EDT_LOCK_LAST_LOGGED.secondsElapsed(600)) {
EDT_LOCK_LAST_LOGGED.set();
// No more often than every 10 minutes, log if EDT is slow
LOGGER.warning("EDT may be slow");
logThreadInfo();
}
}
catch (InterruptedException ex) {
// Do nothing
return;
}
}
}, "EdtLockDetection");
thread.setDaemon(true);
thread.start();
}

/**
* Log a thread dump and try to detect deadlocked threads.
*/
public static void logThreadInfo() {
LOGGER.info("Thread Dump:\n"+threadDump());
logDeadlocks();
Expand Down

0 comments on commit 576822e

Please sign in to comment.