Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - thephpdev

Pages: [1]
1
Support / Error while Multi-Threading
« on: October 21, 2012, 06:47:33 pm »
In my attempts to multi-thread my program, I have run into troubles with getting it to work with JPCT. Here is my error:
Code: [Select]
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.

I have JPCT update the screen and render with a timer thread, which is shown here:
Code: [Select]
frameTimer = new Timer(1000 / FPS, new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (!isInitialized) {
open();
update3D(chunk);
playerProcess.setWidthHeight(buffer.getOutputWidth(), buffer.getOutputHeight());
playerProcess.start();
viewChanged = true;
}
buffer.clear(Color.BLACK);
font.blitString(buffer, "Frame Rate:  " + currentFPS, 5, 15, 0, Color.WHITE);
font.blitString(buffer, "Target Rate: " + FPS, 5, 35, 0, Color.WHITE);
synchronized (world) {
synchronized (player) {
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
}
}
buffer.displayGLOnly();
viewChanged = false;
frameID++;
if (new Date().getTime() - frameSecondTime >= 1000) {
playerProcess.setSpeed(1.2f * (25f / FPS));
frameTimer.setDelay(1000 / FPS);
currentFPS = frameID;
frameID = 0;
frameSecondTime = new Date().getTime();
}
if (!running) {
close();
frameTimer.stop();
Thread.currentThread().interrupt();
}
}
});

And then I have another thread that modifies the camera position and rotations plus the player object, which acts as an easily modifiable class that I want to be able to change at a later date. I create a synchronized block every time I want to modify world or player, both in the timer thread and in my own processing thread. Any idea of how to fix this, or what's wrong?

Pages: [1]