[Polycasso-commit] SF.net SVN: polycasso:[56] trunk/polycasso/src/com/mebigfatguy/polycasso/ ImageG
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-11-26 01:55:33
|
Revision: 56
http://polycasso.svn.sourceforge.net/polycasso/?rev=56&view=rev
Author: dbrosius
Date: 2009-11-26 01:55:18 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
base number of improvers on Runtime.getRuntime().availableProcessors()
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-25 15:05:30 UTC (rev 55)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 01:55:18 UTC (rev 56)
@@ -36,9 +36,6 @@
* This class generates multiple images in parallel to keep multicore processors busy.
*/
public class ImageGenerator implements Runnable {
- private static final int NUM_THREADS = 8;
-
-
private static int attempt = 0;
private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
private PolygonData[] bestData;
@@ -102,8 +99,8 @@
public void startGenerating() {
synchronized(startStopLock) {
if (t == null) {
- t = new Thread[NUM_THREADS];
- for (int i = 0; i < NUM_THREADS; i++) {
+ t = new Thread[Runtime.getRuntime().availableProcessors()];
+ for (int i = 0; i < t.length; i++) {
t[i] = new Thread(this);
t[i].start();
}
@@ -118,10 +115,10 @@
synchronized(startStopLock) {
if (t != null) {
try {
- for (int i = 0; i < NUM_THREADS; i++) {
+ for (int i = 0; i < t.length; i++) {
t[i].interrupt();
}
- for (int i = 0; i < NUM_THREADS; i++) {
+ for (int i = 0; i < t.length; i++) {
t[i].join();
}
} catch (InterruptedException ie) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|