Stopping Thread in Java

前端 未结 1 1285
情深已故
情深已故 2021-01-22 10:58

if i have got such java code:

public static void main(String[] args)
{
    for(int i = 0;i<100;i++)
    {
        Future f = ThreadPoolManager.getIns         


        
1条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 11:46

    cancel(true) calls interrupt() on your thread, nothing more. So, you need to handle it properly in your run() method. For your simple case your threads will finish their execution and their objects will be cleared by GC.

    0 讨论(0)
提交回复
热议问题