相关疑难解决方法(0)

您在Java中遇到的最常见的并发问题是什么?

这是对Java中常见并发问题的一种调查.一个例子可能是经典的死锁或竞争条件,或者可能是Swing中的EDT线程错误.我对各种可能的问题既感兴趣,也对最常见的问题感兴趣.因此,请在每条评论中留下Java并发错误的一个特定答案,如果您看到自己遇到的错误,请立即投票.

java concurrency multithreading

190
推荐指数
28
解决办法
7万
查看次数

我怎么能杀死一个线程?不使用stop();

Thread currentThread=Thread.currentThread();
        public void run()
        {               

             while(!shutdown)
            {                               
                try
                {
                    System.out.println(currentThread.isAlive());
                Thread.interrupted();

                System.out.println(currentThread.isAlive());
                if(currentThread.isAlive()==false)
                {
                    shutdown=true;
                }
                }
                catch(Exception e)
                {
                    currentThread.interrupt();
                }                   
            }
        }

    });
    thread.start();
Run Code Online (Sandbox Code Playgroud)

java multithreading interrupted-exception interruption

24
推荐指数
3
解决办法
8万
查看次数