我正在创建一个通知用户约会时间的系统。我的问题:当用户添加一个新约会时创建一个线程是否很好,该约会将在约会日期时收听并在右下角显示通知我的代码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
提交
取消