好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Java开发中可以防止界面假死的刷新代码

代码如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

try {

   // 创建一个线程

   thread thread = new thread() {

   public void run() {

    int i = 0 ;

    while ( true ){

    final long start = system.currenttimemillis();

    try {

     thread.sleep( 1 );

    } catch (interruptedexception e) {

     // todo auto-generated catch block

     e.printstacktrace();

    }

    final int a = i;

    if (!display.getdefault().isdisposed()) {

     runnable runnable = new runnable() {

     public void run() {

      processmodel.setprocessname(start + "---" + a);

     }

     };

     display.getdefault().syncexec(runnable);

    }

    i++;

    }

   }

   };

   thread.start();

  } catch (exception e) {

   e.printstacktrace();

  }

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/li_canhui/article/details/7057212

查看更多关于Java开发中可以防止界面假死的刷新代码的详细内容...

  阅读:13次