mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
passing a lambda expression to thread constructor
This commit is contained in:
parent
deff384e03
commit
25036d0169
@ -116,14 +116,12 @@ public class RealTimeClock implements ModelStateObserver {
|
|||||||
private final Thread thread;
|
private final Thread thread;
|
||||||
|
|
||||||
ThreadRunner() {
|
ThreadRunner() {
|
||||||
thread = new Thread() {
|
thread = new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
LOGGER.debug("thread start");
|
LOGGER.debug("thread start");
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
long counter = 0;
|
long counter = 0;
|
||||||
try {
|
try {
|
||||||
while (!interrupted()) {
|
while (!Thread.interrupted()) {
|
||||||
modelSync.accessNEx(() -> {
|
modelSync.accessNEx(() -> {
|
||||||
output.setValue(1 - output.getValue());
|
output.setValue(1 - output.getValue());
|
||||||
model.doStep();
|
model.doStep();
|
||||||
@ -138,8 +136,7 @@ public class RealTimeClock implements ModelStateObserver {
|
|||||||
final long l = counter / time / 2;
|
final long l = counter / time / 2;
|
||||||
status.setStatus(l + "kHz");
|
status.setStatus(l + "kHz");
|
||||||
LOGGER.debug("thread end, f=" + l + "kHz");
|
LOGGER.debug("thread end, f=" + l + "kHz");
|
||||||
}
|
});
|
||||||
};
|
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user