本文整理匯總了Java中java.lang.Thread.State.values方法的典型用法代碼示例。如果您正苦於以下問題:Java State.values方法的具體用法?Java State.values怎麽用?Java State.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.Thread.State
的用法示例。
在下文中一共展示了State.values方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculate
import java.lang.Thread.State; //導入方法依賴的package包/類
public void calculate() {
int max = 0;
for(State state:State.values()) {
if(stateCount[state.ordinal()]>max) {
max = stateCount[state.ordinal()];
averageState = state;
}
}
}
示例2: getAsString
import java.lang.Thread.State; //導入方法依賴的package包/類
@Nonnull
@Nonempty
public String getAsString ()
{
final StringBuilder aSB = new StringBuilder ();
// Error always shown first!
if (StringHelper.hasText (m_sError))
aSB.append ("ERROR retrieving all thread stack traces: ").append (m_sError).append ("\n\n");
// Total thread count
aSB.append ("Total thread count: ").append (m_aList.size ()).append ('\n');
// Emit thread IDs grouped by state
final ICommonsMap <State, ICommonsNavigableSet <Long>> aStateMap = _getStateMap ();
for (final State eState : State.values ())
{
final ICommonsSet <Long> aThreadIDs = aStateMap.get (eState);
final int nSize = aThreadIDs.size ();
aSB.append ("Thread state ").append (eState).append (" [").append (nSize).append (']');
if (nSize > 0)
aSB.append (": ").append (aThreadIDs.toString ());
aSB.append ('\n');
}
// Append all stack traces at the end
for (final ThreadDescriptor aDescriptor : m_aList)
aSB.append ('\n').append (aDescriptor.getAsString ());
return aSB.toString ();
}
示例3: getAsMicroNode
import java.lang.Thread.State; //導入方法依賴的package包/類
@Nonnull
public IMicroElement getAsMicroNode ()
{
final IMicroElement eRet = new MicroElement ("threadlist");
if (StringHelper.hasText (m_sError))
eRet.appendElement ("error").appendText (m_sError);
// Overall thread count
eRet.setAttribute ("threadcount", m_aList.size ());
// Emit thread IDs grouped by state
final ICommonsMap <State, ICommonsNavigableSet <Long>> aStateMap = _getStateMap ();
for (final State eState : State.values ())
{
final ICommonsSet <Long> aThreadIDs = aStateMap.get (eState);
final int nSize = aThreadIDs.size ();
final IMicroElement eThreadState = eRet.appendElement ("threadstate");
eThreadState.setAttribute ("id", eState.toString ());
eThreadState.setAttribute ("threadcount", nSize);
if (nSize > 0)
eThreadState.appendText (StringHelper.getImploded (',', aThreadIDs));
}
// Append all stack traces at the end
for (final ThreadDescriptor aDescriptor : m_aList)
eRet.appendChild (aDescriptor.getAsMicroNode ());
return eRet;
}
示例4: Aggregate
import java.lang.Thread.State; //導入方法依賴的package包/類
public Aggregate() {
super();
stateCount = new int[State.values().length];
}