Java Code Examples for java.util.concurrent.RejectedExecutionException#printStackTrace()

The following examples show how to use java.util.concurrent.RejectedExecutionException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmppActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
public void loadBitmap(Message message, ImageView imageView) {
    Bitmap bm;
    try {
        bm = xmppConnectionService.getFileBackend().getThumbnail(message, (int) (metrics.density * 288), true);
    } catch (IOException e) {
        bm = null;
    }
    if (bm != null) {
        cancelPotentialWork(message, imageView);
        imageView.setImageBitmap(bm);
        imageView.setBackgroundColor(0x00000000);
    } else {
        if (cancelPotentialWork(message, imageView)) {
            imageView.setBackgroundColor(0xff333333);
            imageView.setImageDrawable(null);
            final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
            final AsyncDrawable asyncDrawable = new AsyncDrawable(getResources(), null, task);
            imageView.setImageDrawable(asyncDrawable);
            try {
                task.execute(message);
            } catch (final RejectedExecutionException ignored) {
                ignored.printStackTrace();
            }
        }
    }
}
 
Example 2
Source File: ThreadManager.java    From FastAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 在网络线程上执行异步操作. 该线程池负责网络请求等操作
 * 长时间的执行(如网络请求使用此方法执行) 当然也可以执行其他 线程和AsyncTask公用
 *
 * @param run
 */
public static void executeOnNetWorkThread(Runnable run) {
    try {
        NETWORK_EXECUTOR.execute(run);
    } catch (RejectedExecutionException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: AOTCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Enqueue a method in the {@link #compileQueue}.
 *
 * @param method method to be enqueued
 */
private void enqueueMethod(AOTCompiledClass aotClass, ResolvedJavaMethod method) {
    AOTCompilationTask task = new AOTCompilationTask(main, aotClass, method, backend);
    try {
        compileQueue.execute(task);
    } catch (RejectedExecutionException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: ThreadPoolMonitorTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void threadPoolMonitorHasRejectedExecutionsCounter() {
  ThreadPoolMonitor.attach(registry, latchedExecutor, THREAD_POOL_NAME);
  latchedExecutor.shutdown();
  int rejected = 0;
  try {
    latchedExecutor.submit(() -> {});
  } catch (RejectedExecutionException e) {
    e.printStackTrace();
    ++rejected;
  }
  Counter c = registry.counter(ThreadPoolMonitor.REJECTED_TASK_COUNT, "id", THREAD_POOL_NAME);
  Assertions.assertNotNull(c);
  Assertions.assertEquals(rejected, c.count());
}
 
Example 5
Source File: XmppActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public void loadBitmap(Message message, ImageView imageView) {
    Bitmap bm;
    try {
        bm = xmppConnectionService.getFileBackend().getThumbnail(message, (int) (metrics.density * 288), true);
    } catch (IOException e) {
        bm = null;
    }
    if (bm != null) {
        cancelPotentialWork(message, imageView);
        imageView.setImageBitmap(bm);
        imageView.setBackgroundColor(0x00000000);
    } else {
        if (cancelPotentialWork(message, imageView)) {
            imageView.setBackgroundColor(0xff333333);
            imageView.setImageDrawable(null);
            final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
            final AsyncDrawable asyncDrawable = new AsyncDrawable(
                    getResources(), null, task);
            imageView.setImageDrawable(asyncDrawable);
            try {
                task.execute(message);
            } catch (final RejectedExecutionException ignored) {
                ignored.printStackTrace();
            }
        }
    }
}