我遇到了一些在OS X下运行我的Java应用程序中的进程的奇怪行为。以下是我的代码片段:
ProcessBuilder boincBuilder = null;
if(System.getProperty("os.name").toLowerCase().contains("win")) {
boincBuilder = new ProcessBuilder("C:\\Program Files (x86)\\Grid\\BOINC\\boinc.exe");
} else if(System.getProperty("os.name").toLowerCase().contains("mac")) {
boincBuilder = new ProcessBuilder("/Library/Application Support/Grid/boinc", "--dir", "/Library/Application Support/Grid/");
}
try {
Process boinc = boincBuilder.start();
Thread boincOutput = new Thread(new BoincOutput(boinc));
boincOutput.setDaemon(true);
boincOutput.start();
} catch (IOException e) {
e.printStackTrace();
}
当我正常运行程序时,我得到以下输出:
24-Aug-2015 19:53:32 [---] cc_config.xml not found - using defaults
24-Aug-2015 19:53:32 [---] Starting BOINC client version 7.6.7 for x86_64-apple-darwin
24-Aug-2015 19:53:32 [---] log flags: file_xfer, sched_ops, task
24-Aug-2015 19:53:32 [---] Libraries: libcurl/7.39.0 OpenSSL/1.0.1j zlib/1.2.5 c-ares/1.10.0
24-Aug-2015 19:53:32 [---] Data directory: /Library/Application Support/Grid
24-Aug-2015 19:53:32 [---] OpenCL: NVIDIA GPU 0: GeForce GT 650M (driver version 10.4.2 310.41.35f01, device version OpenCL 1.2, 1024MB, 1024MB available, 29 GFLOPS peak)
24-Aug-2015 19:53:32 [---] OpenCL: Intel GPU 0: HD Graphics 4000 (driver version 1.2(Jun 10 2015 16:35:15), device version OpenCL 1.2, 1024MB, 1024MB available, 154 GFLOPS peak)
24-Aug-2015 19:53:32 [---] OpenCL CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (OpenCL driver vendor: Apple, driver version 1.1, device version OpenCL 1.2)
24-Aug-2015 19:53:32 [---] Host name: MacBook-Pro.local
24-Aug-2015 19:53:32 [---] Processor: 8 GenuineIntel Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz [x86 Family 6 Model 58 Stepping 9]
24-Aug-2015 19:53:32 [---] Processor features: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clfsh ds acpi mmx fxsr sse sse2 ss htt tm pbe pni pclmulqdq dtes64 mon dscpl vmx est tm2 ssse3 cx16 tpr pdcm sse4_1 sse4_2 x2apic popcnt aes pcid xsave osxsave tsctmr avx rdrand f16c
24-Aug-2015 19:53:32 [---] OS: Mac OS X 10.10.4 (Darwin 14.4.0)
24-Aug-2015 19:53:32 [---] Memory: 8.00 GB physical, 114.90 GB virtual
24-Aug-2015 19:53:32 [---] Disk: 232.62 GB total, 114.65 GB free
24-Aug-2015 19:53:32 [---] Local time is UTC -3 hours
然而,在Java下,我得到了这个:
24-Aug-2015 19:59:23 [---] cc_config.xml not found - using defaults
24-Aug-2015 19:59:23 [---] Starting BOINC client version 7.6.7 for x86_64-apple-darwin
24-Aug-2015 19:59:23 [---] log flags: file_xfer, sched_ops, task
24-Aug-2015 19:59:23 [---] Libraries: libcurl/7.39.0 OpenSSL/1.0.1j zlib/1.2.5 c-ares/1.10.0
24-Aug-2015 19:59:23 [---] Data directory: /Library/Application Support/Grid
24-Aug-2015 19:59:23 [---] No usable GPUs found
24-Aug-2015 19:59:23 [---] Host name: MacBook-Pro.local
24-Aug-2015 19:59:23 [---] Processor: 8 GenuineIntel Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz [x86 Family 6 Model 58 Stepping 9]
24-Aug-2015 19:59:23 [---] Processor features: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clfsh ds acpi mmx fxsr sse sse2 ss htt tm pbe pni pclmulqdq dtes64 mon dscpl vmx est tm2 ssse3 cx16 tpr pdcm sse4_1 sse4_2 x2apic popcnt aes pcid xsave osxsave tsctmr avx rdrand f16c
24-Aug-2015 19:59:23 [---] OS: Mac OS X 10.10.4 (Darwin 14.4.0)
24-Aug-2015 19:59:23 [---] Memory: 8.00 GB physical, 114.89 GB virtual
24-Aug-2015 19:59:23 [---] Disk: 232.62 GB total, 114.65 GB free
24-Aug-2015 19:59:23 [---] Local time is UTC -3 hours
注意在Java下运行时它是如何找不到任何GPU的。另一个奇怪的行为是我在Activity Monitor下看到两个任务,而在Windows中只创建了一个(这应该是什么)。
这可能是Java中的错误吗?或者程序本身存在问题?