我正在創建一個通知用戶約會時間的系統。我的問題:當用戶添加一個新約會時創建一個線程是否很好,該約會將在約會日期時收聽并在右下角顯示通知我的代碼DateFormat inFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm a");DateFormat outFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");Timer timer = new Timer();private void appointmentNotification() throws ParseException { //Convert 12hour time to 24hour String dateValues = date + " " + time; Date dateParse = inFormat.parse(dateValues); timer.schedule(new TimerTask() { @Override public void run() { Notifications noti = Notifications.create(); noti.text("Doctor "+doc+" has an Appointment with Patient "+patient); noti.title("Appointment"); noti.hideAfter(Duration.seconds(10)); noti.position(Pos.BOTTOM_RIGHT); Platform.runLater(new Runnable() { @Override public void run() { noti.show(); } }); } }, outFormat.parse(outFormat.format(dateParse)));}我想如果用戶添加了 50 個約會,就會有 50 個線程在運行
添加回答
舉報
0/150
提交
取消