Skip to content

Commit

Permalink
reduce update priority
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Apr 24, 2024
1 parent 5bd2e58 commit 0188d4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class LogPaneSample extends Application {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
}

public static final int AVERAGE_SLEEP_MILLIS = 100;
public static final int LOG_BUFFER_SIZE = 1000;
public static final int AVERAGE_SLEEP_MILLIS = 10;
public static final int LOG_BUFFER_SIZE = 10000;
private final org.slf4j.Logger SLF4J_LOGGER = LoggerFactory.getLogger("SLF4J." + getClass().getName());
private final java.util.logging.Logger JUL_LOGGER = java.util.logging.Logger.getLogger("JUL." + getClass().getName());
private final org.apache.logging.log4j.Logger LOG4J_LOGGER = org.apache.logging.log4j.LogManager.getLogger("LOG4J." + getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
final class LogEntriesObservableList extends ObservableListBase<LogEntry> implements LogBuffer.LogBufferListener {
private static final Logger LOG = LogManager.getLogger(LogEntriesObservableList.class);

private final LogBuffer buffer;
private static final long REST_TIME_IN_MS = 10;

private volatile List<LogEntry> data = Collections.emptyList();
private final AtomicInteger queuedRemoves = new AtomicInteger();

Expand All @@ -37,7 +38,6 @@ final class LogEntriesObservableList extends ObservableListBase<LogEntry> implem
* @throws NullPointerException if the buffer is null
*/
LogEntriesObservableList(LogBuffer buffer) {
this.buffer = buffer;
buffer.addLogBufferListener(this);

Thread updateThread = new Thread(() -> {
Expand Down Expand Up @@ -74,8 +74,14 @@ final class LogEntriesObservableList extends ObservableListBase<LogEntry> implem
} finally {
updateWriteLock.unlock();
}
try {
Thread.sleep(REST_TIME_IN_MS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}, "LogTableModel Update Thread");
updateThread.setPriority(Thread.NORM_PRIORITY - 1);
updateThread.setDaemon(true);
updateThread.start();
}
Expand Down

0 comments on commit 0188d4e

Please sign in to comment.