thread the thread handler
parent
046d92a87a
commit
ed528cb670
|
@ -17,7 +17,7 @@ public class DynamicChunkLoader extends GingerThread{
|
|||
this.chunkY = chunkY;
|
||||
this.chunkZ = chunkZ;
|
||||
this.world = world;
|
||||
this.setName("DynamicChunk thread");
|
||||
this.setName("Dynamic Chunk thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -119,6 +119,7 @@ public class Ginger
|
|||
|
||||
public void startGame()
|
||||
{
|
||||
threading.start();
|
||||
while (!Window.closed())
|
||||
{
|
||||
Litecraft.getInstance().ups++;
|
||||
|
@ -133,7 +134,6 @@ public class Ginger
|
|||
|
||||
public void update(GameData data)
|
||||
{
|
||||
threading.update();
|
||||
data.camera.move();
|
||||
GingerUtils.update();
|
||||
picker.update();
|
||||
|
|
|
@ -3,8 +3,9 @@ package com.github.hydos.multiThreading;
|
|||
import java.util.*;
|
||||
|
||||
import com.github.halotroop.litecraft.Litecraft;
|
||||
import com.github.hydos.ginger.engine.io.Window;
|
||||
|
||||
public class GingerThreading
|
||||
public class GingerThreading extends Thread
|
||||
{
|
||||
public List<GingerThread> worldChunkThreadWaitlist;
|
||||
|
||||
|
@ -14,21 +15,23 @@ public class GingerThreading
|
|||
public void registerChunkThreadToWaitlist(GingerThread thread)
|
||||
{ worldChunkThreadWaitlist.add(thread); }
|
||||
|
||||
public void update() {
|
||||
if(worldChunkThreadWaitlist.size() != 0) {
|
||||
Litecraft.getInstance().threadWaitlist = worldChunkThreadWaitlist.size();
|
||||
GingerThread yes = worldChunkThreadWaitlist.get(0);
|
||||
if(yes.finished) {
|
||||
worldChunkThreadWaitlist.remove(0);
|
||||
if(worldChunkThreadWaitlist.size() != 0) {
|
||||
worldChunkThreadWaitlist.get(0).start();
|
||||
}
|
||||
}else {
|
||||
if(!yes.isAlive() && !yes.started) {
|
||||
yes.start();
|
||||
@Override
|
||||
public void run() {
|
||||
while(!Window.closed()) {
|
||||
if(worldChunkThreadWaitlist.size() != 0) {
|
||||
Litecraft.getInstance().threadWaitlist = worldChunkThreadWaitlist.size();
|
||||
GingerThread yes = worldChunkThreadWaitlist.get(0);
|
||||
if(yes.finished) {
|
||||
worldChunkThreadWaitlist.remove(0);
|
||||
if(worldChunkThreadWaitlist.size() != 0) {
|
||||
worldChunkThreadWaitlist.get(0).start();
|
||||
}
|
||||
}else {
|
||||
if(!yes.isAlive() && !yes.started) {
|
||||
yes.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue