Skip to content

Commit

Permalink
#39 daemon thread factory removed; memory unit moved to vjkit; develo…
Browse files Browse the repository at this point in the history
…per added;
  • Loading branch information
ben04.li committed Jun 21, 2018
1 parent b55e9d3 commit f9426bb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.vip.vjstar.gc;
package com.vip.vjtools.vjkit.text;

/**
* Representation of basic memory units.<br/>
Expand Down
9 changes: 9 additions & 0 deletions vjstar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,14 @@
</roles>
<timezone>+8</timezone>
</developer>
<developer>
<id>lixuanbin</id>
<name>Xuanbin.Li</name>
<email>ben04.li at vipshop.com</email>
<roles>
<role>developer</role>
</roles>
<timezone>+8</timezone>
</developer>
</developers>
</project>
20 changes: 0 additions & 20 deletions vjstar/src/main/java/com/vip/vjstar/gc/DaemonThreadFactory.java

This file was deleted.

2 changes: 2 additions & 0 deletions vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vip.vjtools.vjkit.text.MemoryUnit;

/**
* Detect old gen usage of current jvm periodically and trigger a cms gc if necessary.<br/>
* In order to enable this feature, add these options to your target jvm:<br/>
Expand Down
16 changes: 8 additions & 8 deletions vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTaskDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProactiveGcTaskDemo {
public static void main(String[] args) throws IOException {
Logger logger = LoggerFactory.getLogger(ProactiveGcTaskDemo.class);
final Enchanter enchanter = new Enchanter();
enchanter.makeGarbage("50000000");
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1,
new DaemonThreadFactory("GcTaskScheduler"));
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new ThreadFactory() {
public Thread newThread(Runnable runnable) {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);
return thread;
}
});
List<Long> times = DateTimeUtil.getDelayMillisList4ProactiveGcTask("03:30-04:30");
for (long time : times) {
// Schedule gc task at the specified random delay, and repeat it every other day.
ProactiveGcTask task = new ProactiveGcTask(scheduler, 50, 48, TimeUnit.HOURS) {
@Override
public void preGc() {
super.preGc();
enchanter.clearGarbage();
}
@Override
public void postGc() {
super.postGc();
System.exit(1);
Expand Down

0 comments on commit f9426bb

Please sign in to comment.