JavaFX : Use a Thread more than once

前端 未结 3 2254
天命终不由人
天命终不由人 2021-02-20 14:38

I\'m new with JavaFX and I\'ve a little problem with a thread: I can execute it twice and I can\'t find why.

Here is a sum-upt of my code:

Task

        
3条回答
  •  时光说笑
    2021-02-20 15:02

    With a button can fire new tasks

                        Button btn = new Button();
                        btn.setText("New task");
                        btn.setOnAction(new EventHandler() {
                            @Override
                            public void handle(ActionEvent event) {
                                Executor ex=new Executor("Task"+count);
                                ex.start();
                                count++;
                                System.out.println("Task  Starting...");
                            }
                        });
    

提交回复
热议问题