为什么 JavaFX 包含重复的颜色常量?

查看JavaFX 11的 API 文档,我发现它包含重复的颜色常量。例如:

  • DARKGRAY - RGB 值为深灰色的颜色#A9A9A9

  • DARKGREY - RGB 值为深灰色的颜色#A9A9A9

  • GRAY - RGB 值为灰色的颜色#808080

  • GRAY - RGB 值为灰色的颜色#808080

如您所见,唯一的区别在于字段名称的拼写,而不是 RGB 值。你知道为什么会有这样的重复吗?


炎炎设计
浏览 138回答 2
2回答

慕尼黑8549860

我有一些课:@Componentpublic MyClass {&nbsp; &nbsp;private volatile boolean stopped = false;&nbsp;&nbsp; &nbsp;public void verification() throws Exception {&nbsp; &nbsp; &nbsp; &nbsp; Thread kpiAllThread = getKPIAllThread();&nbsp; &nbsp; &nbsp; &nbsp; try {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i < poolSize; i++) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execDispatcher.put(processExecutor.submit(getCheckValuesInKPIConsumerTask(workingQueue)));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kpiAllThread.start();&nbsp; &nbsp; &nbsp; &nbsp; } finally {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; waitFinished();&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; public void setStop(bolean stopped) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.stopped = stopped;&nbsp; &nbsp; }&nbsp; &nbsp; private Thread getKPIAllThread() {&nbsp; &nbsp; &nbsp; &nbsp; return new Thread(() -> {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOG.debug("KPIAllThread started!");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dao.getKpiAll(workingQueue);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i < poolSize; i++) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; workingQueue.put(() -> true);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception ex) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOG.error("KPIAllThread exception: ", ex);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } finally {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOG.error("KPIAllThread finished!");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; }}这个类启动生产者线程getKPIAllThread。他从 db 获取数据并放入BlockingQueue.getKpiAll像这样的方法:public void getKpiAll(final BlockingQueue<KeyPropertyIndex> kpiData) throws Exception {&nbsp; &nbsp; &nbsp; &nbsp; LOG.debug("Starting getKpiAll");&nbsp; &nbsp; &nbsp; &nbsp; try (final Connection con = dataSource.getConnection();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;final Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stmt.setFetchSize(Integer.MIN_VALUE);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try (final ResultSet rs = stmt.executeQuery(sqlGetAllkpi)) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (rs.next()) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kpiData.put(new KeyPropertyIndexData(rs.getLong(1), rs.getString(2)));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOG.debug("Finished get getKpiAll");&nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception ex) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw ex;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }还有一个变量stopped可以从外部设置到true. 这样做时如何安全地停止我的线程?这样到数据库的所有连接都关闭并且线程成功完成?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java