本文整理匯總了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);
}