Display name when java swing thread debugging

 

Generally have a default name

But where to run a specific thread, you need to guess

To save time, improve efficiency

You can write to thread a Chinese name (because the default is English, Chinese writing, one can pick out)

As an example to the RTC timer

 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();

        }
    });

However, running too fast, you can not see

You can choose a relatively large amount of time spent threads, such as heartbeat packet transmission

After sending the client to the server should detect a heartbeat packet response, so it is necessary for several seconds

Enough to see, and, under the map, find this thread

 

Guess you like

Origin www.cnblogs.com/jnhs/p/11257761.html