Browse Source

REPORT-19947 关停应用时线程残留问题优化

research/11.0
vito 5 years ago
parent
commit
34f6292dc2
  1. 22
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 34
      designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java
  3. 36
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java

22
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -2,6 +2,7 @@ package com.fr.design.data;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils;
@ -30,14 +31,14 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.*;
import java.io.ByteArrayOutputStream;
import java.text.Collator;
import java.util.ArrayList;
@ -48,8 +49,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 设计器管理操作数据集的类:
@ -444,11 +445,18 @@ public abstract class DesignTableDataManager {
} catch (Exception e) {
throw new TableDataException(e.getMessage(), e);
} finally {
new Timer().schedule(new TimerTask() {
ScheduledExecutorService scheduledExecutorService = ModuleContext
.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory(""));
scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
loadingBar.close();
if (loadingBar != null) {
loadingBar.close();
}
}
}, 100);
}, 100, TimeUnit.MILLISECONDS);
scheduledExecutorService.shutdown();
}
}

34
designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java

@ -1,10 +1,14 @@
package com.fr.design.gui.style;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.module.ModuleContext;
import com.fr.value.ClearableLazyValue;
import org.jetbrains.annotations.NotNull;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created with IntelliJ IDEA.
@ -14,31 +18,35 @@ import java.util.TimerTask;
* To change this template use File | Settings | File Templates.
*/
public class FormatePaneNumField extends UITextField {
private Timer timer;
private ClearableLazyValue<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@NotNull
@Override
protected ScheduledExecutorService compute() {
return ModuleContext.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange"));
}
};
public FormatePaneNumField() {
super();
}
@Override
protected void attributeChange() {
if (!AbstractAttrNoScrollPane.isHasChangeListener()) {
return;
}
if(timer != null){
timer.cancel();
}
timer = new Timer();
timer.schedule(new TimerTask() {
ses.getValue().schedule(new Runnable() {
@Override
public void run() {
runChange();
}
},100);
}, 100, TimeUnit.MILLISECONDS);
}
protected void runChange(){
protected void runChange() {
super.attributeChange();
timer.cancel();
ses.getValue().shutdown();
ses.drop();
}
}

36
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java

@ -1,9 +1,13 @@
package com.fr.design.mainframe.chart.gui.style.series;
import java.util.Timer;
import java.util.TimerTask;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.module.ModuleContext;
import com.fr.value.ClearableLazyValue;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created with IntelliJ IDEA.
@ -13,28 +17,34 @@ import com.fr.design.gui.itextfield.UINumberField;
* To change this template use File | Settings | File Templates.
*/
public class ColorPickerPaneNumFiled extends UINumberField {
private Timer timer;
private ClearableLazyValue<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@NotNull
@Override
protected ScheduledExecutorService compute() {
return ModuleContext.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange"));
}
};
public ColorPickerPaneNumFiled() {
super();
}
@Override
protected void attributeChange() {
if(timer != null){
timer.cancel();
}
timer = new Timer();
timer.schedule(new TimerTask() {
ses.getValue().schedule(new Runnable() {
@Override
public void run() {
// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应.
runChange();
}
},500);// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应.
}, 500, TimeUnit.MILLISECONDS);
}
protected void runChange(){
protected void runChange() {
super.attributeChange();
timer.cancel();
ses.getValue().shutdown();
ses.drop();
}

Loading…
Cancel
Save