本文整理汇总了Java中java.lang.management.ThreadInfo.from方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadInfo.from方法的具体用法?Java ThreadInfo.from怎么用?Java ThreadInfo.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.ThreadInfo
的用法示例。
在下文中一共展示了ThreadInfo.from方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: badNameCompositeData
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
public static void badNameCompositeData() throws Exception {
CompositeType ct =
new CompositeType("MyCompositeType",
"CompositeType for ThreadInfo",
badItemNames,
badItemNames,
validItemTypes);
CompositeData cd =
new CompositeDataSupport(ct,
badItemNames,
values);
try {
ThreadInfo info = ThreadInfo.from(cd);
} catch (IllegalArgumentException e) {
System.out.println("Expected exception: " +
e.getMessage());
return;
}
throw new RuntimeException(
"IllegalArgumentException not thrown");
}
示例2: createV5ThreadInfo
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
public static void createV5ThreadInfo() throws Exception {
String[] v5ItemNames = new String[NUM_V5_ATTS];
OpenType[] v5ItemTypes = new OpenType[NUM_V5_ATTS];
Object[] v5ItemValues = new Object[NUM_V5_ATTS];
for (int i = 0; i < NUM_V5_ATTS; i++) {
v5ItemNames[i] = validItemNames[i];
v5ItemTypes[i] = validItemTypes[i];
v5ItemValues[i] = values[i];
}
CompositeType ct =
new CompositeType("MyCompositeType",
"CompositeType for JDK 5.0 ThreadInfo",
v5ItemNames,
v5ItemNames,
v5ItemTypes);
CompositeData cd =
new CompositeDataSupport(ct,
v5ItemNames,
v5ItemValues);
ThreadInfo info = ThreadInfo.from(cd);
checkThreadInfo(info);
}
示例3: badTypeCompositeData
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
public static void badTypeCompositeData() throws Exception {
CompositeType ct =
new CompositeType("MyCompositeType",
"CompositeType for ThreadInfo",
validItemNames,
validItemNames,
badItemTypes);
// patch values[STACK_TRACE] to Long
values[STACK_TRACE] = new Long(1000);
values[LOCK_INFO] = new Long(1000);
CompositeData cd =
new CompositeDataSupport(ct,
validItemNames,
values);
try {
ThreadInfo info = ThreadInfo.from(cd);
} catch (IllegalArgumentException e) {
System.out.println("Expected exception: " +
e.getMessage());
return;
}
throw new RuntimeException(
"IllegalArgumentException not thrown");
}
示例4: getThreads
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
public ThreadInfo[] getThreads() {
synchronized (tinfoLock) {
if (tinfos == null) {
int i = 0;
tinfos = new ThreadInfo[cdThreads.length];
for (Object cd : cdThreads) {
tinfos[i++] = ThreadInfo.from((CompositeData) cd);
}
cdThreads = null;
}
return tinfos;
}
}
示例5: addStacktrace
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
private void addStacktrace(java.lang.management.ThreadInfo[] tinfos, long time) {
java.lang.management.ThreadInfo[] newInfo = new java.lang.management.ThreadInfo[tinfos.length];
int i = 0;
for (java.lang.management.ThreadInfo tinfo : tinfos) {
CompositeData aaa = ThreadInfoCompositeData.toCompositeData(tinfo);
newInfo[i++] = ThreadInfo.from(aaa);
}
instance.addStacktrace(newInfo, time);
}
示例6: createGoodCompositeData
import java.lang.management.ThreadInfo; //导入方法依赖的package包/类
public static void createGoodCompositeData() throws Exception {
CompositeType ct =
new CompositeType("MyCompositeType",
"CompositeType for ThreadInfo",
validItemNames,
validItemNames,
validItemTypes);
CompositeData cd =
new CompositeDataSupport(ct,
validItemNames,
values);
ThreadInfo info = ThreadInfo.from(cd);
checkThreadInfo(info);
}