java.util.ConcurrentModificationException.printStackTrace()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中java.util.ConcurrentModificationException.printStackTrace()方法的一些代码示例,展示了ConcurrentModificationException.printStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentModificationException.printStackTrace()方法的具体详情如下:
包路径:java.util.ConcurrentModificationException
类名称:ConcurrentModificationException
方法名:printStackTrace

ConcurrentModificationException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: oblac/jodd

/**
 * http://code.google.com/p/jodd/issues/detail?id=4
 */
@Test
void testPutGetAndPrune() throws InterruptedException {
  LFUCache<String, String> lfuCache = new LFUCache<>(2, 0);
  lfuCache.put("1", "value");
  assertFalse(lfuCache.isFull());
  lfuCache.put("2", "value");
  assertTrue(lfuCache.isFull());
  lfuCache.get("2");
  lfuCache.get("2");
  assertEquals(2, lfuCache.size());
  Semaphore semaphore = new Semaphore(2);
  Thread1 t1 = new Thread1(semaphore, lfuCache);
  Thread2 t2 = new Thread2(semaphore, lfuCache);
  t1.start();
  t2.start();
  semaphore.acquire();
  if (t1.exception != null) {
    t1.exception.printStackTrace();
  }
  assertNull(t1.exception);
  if (t2.exception != null) {
    t2.exception.printStackTrace();
  }
  assertNull(t2.exception);
}

代码示例来源:origin: UniversaBlockchain/universa

public void traceErrors() {
  try {
    for (ErrorRecord er : errors) {
      System.out.println("Error: " + er);
    }
  } catch (ConcurrentModificationException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.python/jython

/**
 * If no objects are monitored, this just delegates to
 * {@code System.gc()} and returns {@link #UNKNOWN_COUNT} as a
 * non-erroneous default value. If objects are monitored,
 * it emulates a synchronous gc-run in the sense that it waits
 * until all collected monitored objects were finalized.
 * 
 * @return Number of collected monitored cyclic trash-objects
 * or {@link #UNKNOWN_COUNT} if nothing is monitored or -1
 * if an error occurred and collection did not complete.
 * @see #UNKNOWN_COUNT
 * @see #collect(int)
 */
public static int collect() {
  try {
    return collect_intern();
  } catch (java.util.ConcurrentModificationException cme) {
    cme.printStackTrace();
  } catch (NullPointerException npe) {
    npe.printStackTrace();
  } 
  return -1;
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
 public void run() {
  while(runThread) {
   try {
    UserGroupInformation.getCurrentUser().getCredentials();
   } catch (ConcurrentModificationException cme) {
    this.cme = cme;
    cme.printStackTrace();
    runThread = false;
   } catch (IOException ex) {
    ex.printStackTrace();
   }
  }
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
 public void run() {
  while(runThread) {
   try {
    UserGroupInformation.getCurrentUser().getCredentials();
   } catch (ConcurrentModificationException cme) {
    this.cme = cme;
    cme.printStackTrace();
    runThread = false;
   } catch (IOException ex) {
    ex.printStackTrace();
   }
  }
 }
}

代码示例来源:origin: apache/activemq-artemis

t.printStackTrace();
} catch (InterruptedException e) {
  t.printStackTrace();
} catch (InterruptedException e) {

代码示例来源:origin: apache/activemq-artemis

} catch (ConcurrentModificationException t) {
  hasError.set(true);
  t.printStackTrace();
} catch (InterruptedException e) {
  t.printStackTrace();
} catch (InterruptedException e) {

代码示例来源:origin: IntellectualSites/PlotSquared

e.printStackTrace();

代码示例来源:origin: eu.mihosoft.vrl/vrl

ex.printStackTrace(System.err);

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
  public Void run() throws Exception {
   // make sure it is not the same as the login user because we use the
   // same UGI object for every instantiation of the login user and you
   // won't run into the race condition otherwise
   assertNotEquals(UserGroupInformation.getLoginUser(),
           UserGroupInformation.getCurrentUser());
   GetTokenThread thread = new GetTokenThread();
   try {
    thread.start();
    for (int i = 0; i < 100; i++) {
     @SuppressWarnings("unchecked")
     Token<? extends TokenIdentifier> t = mock(Token.class);
     when(t.getService()).thenReturn(new Text("t" + i));
     UserGroupInformation.getCurrentUser().addToken(t);
     assertNull("ConcurrentModificationException encountered",
       thread.cme);
    }
   } catch (ConcurrentModificationException cme) {
    cme.printStackTrace();
    fail("ConcurrentModificationException encountered");
   } finally {
    thread.runThread = false;
    thread.join(5 * 1000);
   }
   return null;
  }});
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
  public Void run() throws Exception {
   // make sure it is not the same as the login user because we use the
   // same UGI object for every instantiation of the login user and you
   // won't run into the race condition otherwise
   assertNotEquals(UserGroupInformation.getLoginUser(),
           UserGroupInformation.getCurrentUser());
   GetTokenThread thread = new GetTokenThread();
   try {
    thread.start();
    for (int i = 0; i < 100; i++) {
     @SuppressWarnings("unchecked")
     Token<? extends TokenIdentifier> t = mock(Token.class);
     when(t.getService()).thenReturn(new Text("t" + i));
     UserGroupInformation.getCurrentUser().addToken(t);
     assertNull("ConcurrentModificationException encountered",
       thread.cme);
    }
   } catch (ConcurrentModificationException cme) {
    cme.printStackTrace();
    fail("ConcurrentModificationException encountered");
   } finally {
    thread.runThread = false;
    thread.join(5 * 1000);
   }
   return null;
  }});
}

相关文章