• 求解,多线程时,线程池中一个线程内部代码抛出异常,那么这个线程能正常结束么?


    首先建立线程池

    ExecutorService pool = Executors.newFixedThreadPool(1000);
    pool.submit(new HandlerSocket(client));
    

    然后,实现多线程,

    当一个线程出现异常时:如下

    pool-1-thread-1
    javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
    	at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:913)
    	at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
    	at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
    	at javax.crypto.Cipher.doFinal(Cipher.java:2165)
    	at EncryptOrDecrypt.decryptString(EncryptOrDecrypt.java:173)
    	at HandlerSocket.parseRequestHead(HandlerSocket.java:29)
    	at HandlerSocket.run(HandlerSocket.java:37)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    接入数据...
    pool-2-thread-1
    {"ECOrderId":"456789125","OrderList":[{"PID":"100000","Phones":"18064121114,18150123459"}]}
    

    如上:pool-1-thread-1这个线程异常了,他还能正常结束,等待执行下次线程的分配么,还是一直占着这个线程卡死在那里?

    其中pool-2-thread-1这个线程池中的线程被正常支行了

  • 相关阅读:
    利用wget下载文件,并保存到指定目录
    tar命令详解
    Ubuntu 16.04中安装Chromium浏览器
    怎么打开unity tweak tool
    WPS for linux不能使用中文输入法
    Window7 驱动编程环境配置
    Windows内核 字符串基本操作
    Windows内核 语言选择注意点
    Windows内核 内存管理基本概念
    Windows内核 WDM驱动程序的基本结构和实例
  • 原文地址:https://www.cnblogs.com/yubolin/p/5288396.html
Copyright © 2020-2023  润新知