一般有一个默认名字

java swing调试时线程显示名字

但是具体运行到哪一个线程,需要猜

为了节约时间,提高效率

可以给线程写个中文名(因为默认就是英文,写中文,一眼就能挑出来)

以RTC定时器为例子

 final TimerRtc timerRtc = new TimerRtc(1000, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Thread("rtc实时时钟") {
                @Override
                public void run() {
                    DateTime dateTime = new DateTime(); //获取当前时间
                    int second = dateTime.getSecondOfMinute();
                    int minute = dateTime.getMinuteOfHour();
                    int hour = dateTime.getHourOfDay();
                    if (hour == 23 && minute == 58 && second > 1) {
                        AccountService as = new AccountService();
                        as.setAllValid();//新的一天,全部有效
                    }
                    jlabCurrentDt.setText(dateTime.toString("yyyy-MM-dd  HH:mm:ss"));
                }
            }.start();

        }
    });

不过,运行太快了,是看不到的

那么可以选用一个耗时间比较大的线程,比如心跳包发送

客户端给服务器发送心跳包之后还要检测响应,所以需要好几秒

足够看的了,,下图,找到这个线程

java swing调试时线程显示名字

 

相关文章:

  • 2022-12-23
  • 2021-07-14
  • 2021-05-23
  • 2022-12-23
  • 2021-09-14
  • 2021-09-28
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-23
相关资源
相似解决方案