From 9407f4c3d0f7263de744d3bb2bb52bf653c6dc35 Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Tue, 5 Jul 2011 15:56:32 +0000 Subject: [PATCH] * delayed creation of TerrainQuad executorService unless absolutely needed git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7823 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/terrain/geomipmap/TerrainQuad.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java index bb0643b32..f8c520685 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java +++ b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java @@ -105,16 +105,18 @@ public class TerrainQuad extends Node implements Terrain { private TerrainPicker picker; - - protected ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactory() { - public Thread newThread(Runnable r) { - Thread th = new Thread(r); - th.setName("jME Terrain Thread"); - th.setDaemon(true); - return th; - } - }); - + protected ExecutorService executor; + + protected ExecutorService createExecutorService() { + return Executors.newSingleThreadExecutor(new ThreadFactory() { + public Thread newThread(Runnable r) { + Thread th = new Thread(r); + th.setName("jME Terrain Thread"); + th.setDaemon(true); + return th; + } + }); + } public TerrainQuad() { super("Terrain"); @@ -229,6 +231,9 @@ public class TerrainQuad extends Node implements Terrain { return; // we just want the root quad to perform this. } + if (executor == null) + executor = createExecutorService(); + UpdateLOD updateLodThread = new UpdateLOD(locations); executor.execute(updateLodThread); }