方法内创建的线程,为什么方法结束了线程还不释放内存
publicclassMailboxIndexerCreaterextendsTimerTask{publicMailboxIndexerCreater(Mailboxs...
public class MailboxIndexerCreater extends TimerTask{
public MailboxIndexerCreater(Mailboxs mailboxs, String work_dir){
new Timer().schedule(this, Time.MINUTE * 0);
}
public void run(){
initLuceneSearch();
system.out.println(“initialize lucene seccessfully”);
}
private void initLuceneSearch() {
for (int i = 0; i < 100; i++) {
Mailbox mailbox = (Mailbox) list.get(i);
createIndex(mailbox);
}
}
private void createIndex(Mailbox mailbox) {
for(int i = 0; i < 13; i++){
threads[i] = new IndexThread(mailbox, i + START_YEAR, password, fileIndex);
threads[i].start();
}
threads = null;
System.gc();
return;
}
大致代码结构如上,都提示nitialize lucene seccessfully了,可是从资源管理器中看到java的内存从这方法开始到结束占用了2个G的资源不会释放,求高手解答 展开
public MailboxIndexerCreater(Mailboxs mailboxs, String work_dir){
new Timer().schedule(this, Time.MINUTE * 0);
}
public void run(){
initLuceneSearch();
system.out.println(“initialize lucene seccessfully”);
}
private void initLuceneSearch() {
for (int i = 0; i < 100; i++) {
Mailbox mailbox = (Mailbox) list.get(i);
createIndex(mailbox);
}
}
private void createIndex(Mailbox mailbox) {
for(int i = 0; i < 13; i++){
threads[i] = new IndexThread(mailbox, i + START_YEAR, password, fileIndex);
threads[i].start();
}
threads = null;
System.gc();
return;
}
大致代码结构如上,都提示nitialize lucene seccessfully了,可是从资源管理器中看到java的内存从这方法开始到结束占用了2个G的资源不会释放,求高手解答 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询