⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadstackimpl11.java

📁 JMule是一个基于Java开发
💻 JAVA
字号:
/* ******************************************************************* * Copyright (c) 2004 IBM Corporation *  * All rights reserved.  * This program and the accompanying materials are made available  * under the terms of the Eclipse Public License v1.0  * which accompanies this distribution and is available at  * http://www.eclipse.org/legal/epl-v10.html  *   * Contributors:  *    Andy Clement     initial implementation  * 					   Copied from bits of original CFlowStack * ******************************************************************/package org.aspectj.runtime.internal.cflowstack;import java.util.Enumeration;import java.util.Hashtable;import java.util.Stack;public class ThreadStackImpl11 implements ThreadStack {	private Hashtable stacks = new Hashtable();	private Thread cached_thread;	private Stack cached_stack;	private int change_count = 0;	private static final int COLLECT_AT = 20000;	private static final int MIN_COLLECT_AT = 100; 	public synchronized Stack getThreadStack() {		if (Thread.currentThread() != cached_thread) {			cached_thread = Thread.currentThread();			cached_stack = (Stack)stacks.get(cached_thread);			if (cached_stack == null) {				cached_stack = new Stack();				stacks.put(cached_thread, cached_stack);			}			change_count++;			// Collect more often if there are many threads, but not *too* often			int size = Math.max(1, stacks.size()); // should be >1 b/c always live threads, but...			if (change_count > Math.max(MIN_COLLECT_AT, COLLECT_AT/size)) {				Stack dead_stacks = new Stack();				for (Enumeration e = stacks.keys(); e.hasMoreElements(); ) {					Thread t = (Thread)e.nextElement();					if (!t.isAlive()) dead_stacks.push(t);				}				for (Enumeration e = dead_stacks.elements(); e.hasMoreElements(); ) {					Thread t = (Thread)e.nextElement();					stacks.remove(t);				}				change_count = 0;			}		}		return cached_stack;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -