0

I'am a beginner programmer and I'm trying to learn LWJGL following. I got stuck with this tutorial about reproducing Flappy Birds with LWJGL, the same of the guy who asked this question.

I'm using Eclipse on a MacBook Pro Retina.

The problem is this

Exception in thread "Game" java.lang.IllegalStateException: Please run the JVM with -XstartOnFirstThread. at org.lwjgl.system.macosx.EventLoop.checkFirstThread(EventLoop.java:20) at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:428) at com.cherno.flappy.Main.init(Main.java:41) at com.cherno.flappy.Main.run(Main.java:65) at java.lang.Thread.run(Thread.java:745)

Given by this code:

package com.cherno.flappy;

import static org.lwjgl.glfw.GLFW.*;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;

import java.nio.ByteBuffer;

import org.lwjgl.glfw.GLFWvidmode;

public class Main implements Runnable {


private int width = 1280;
private int height = 720;

private boolean running = false;

private Thread thread;

/*window è un long perché lwjgl è un bindng di c in java.
 * Non esistono oggetti in c, solo id, ed ecco cosa abbiamo.
 */
private long window;

public void start() {

    running = true;
    thread = new Thread(this, "Game"); //Punto (A)
    thread.start(); //Lo start fa partire il run di sotto
}

/*Inizializzo OpenGL qui dentro
 * OpenGL gira in un thread solo!! RICORDALO
 */
private void init() {
    if (glfwInit() != GL_TRUE) {
        //Handle it
        return;
    }

    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    //Creo la finestra e mi faccio tornare il puntatore di C
    window = glfwCreateWindow(width, height, "Flappy", NULL, NULL);
    //Vedo se la finestra è creata
    if (window == NULL) {
        //MAke something
        return;
    }

    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    //Decido la posizione della finestra
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode)-width)/2, (GLFWvidmode.height(vidmode)-height)/2);
    //Setto il contesto per OpenGL
    glfwMakeContextCurrent(window);
    //Mostro la finestra
    glfwShowWindow(window);
}

public void run() {     
    init();

    while(running) {
        update();
        render();

        //Controllo se l'utente vuole uscire
        if(glfwWindowShouldClose(window) == GL_TRUE) running = false;
    }       
}

private void update() {
    glfwPollEvents();
}

private void render() {
    glfwSwapBuffers(window);
}

public static void main(String args[]) {

    new Main().start();

}
}

The exception clearly asks me to start the jvm with -XstartOnThread argument. I do it going to "run > run configuration > arguments tab > vm arguments" in Eclipse and type "-XstartOnThread"; then i click "run" and I get this error:

Process: java [569] Path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java Identifier: java Version: 1.0 (1.0) Code Type: X86-64 (Native) Parent Process: eclipse [478] Responsible: eclipse [478] User ID: 501

Date/Time: 2015-08-06 21:41:32.956 +0200 OS Version:
Mac OS X 10.10.4 (14E46) Report Version: 11 Anonymous UUID:
CBCCB665-9B7F-C8CC-612E-828FAD3AA52D

Time Awake Since Boot: 1500 seconds

Crashed Thread: 20 Java: Game

Exception Type: EXC_CRASH (SIGABRT) Exception Codes:
0x0000000000000000, 0x0000000000000000

Application Specific Information: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.' terminating with uncaught exception of type NSException abort() called

Application Specific Backtrace 1: 0 CoreFoundation
0x00007fff879b203c __exceptionPreprocess + 172 1 libobjc.A.dylib
0x00007fff89d8676e objc_exception_throw + 43 2 CoreFoundation
0x00007fff879b1e1a +[NSException raise:format:arguments:] + 106 3
Foundation 0x00007fff8e3178cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4
Foundation 0x00007fff8e29957f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156 5 AppKit 0x00007fff87f51c41 -[NSApplication run] + 928 6 liblwjgl.dylib
0x0000000121828a2e _glfwPlatformCreateWindow + 1406 7 liblwjgl.dylib 0x0000000121824d9b glfwCreateWindow + 443 8 ???
0x000000010977e954 0x0 + 4453820756 9 ???
0x0000000109770760 0x0 + 4453762912 10 ???
0x0000000109770760 0x0 + 4453762912 11 ???
0x0000000109770c4d 0x0 + 4453764173 12 ???
0x0000000109770c92 0x0 + 4453764242

Thread 0:: Dispatch queue: com.apple.main-thread 0
libsystem_kernel.dylib 0x00007fff8a578136 psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c48fc2 Monitor::wait(bool, long, bool) + 246 5 libjvm.dylib
0x0000000108d4990e Threads::destroy_vm() + 80 6 libjvm.dylib
0x0000000108b15e43 jni_DestroyJavaVM + 254 7 java
0x0000000107d7b2b2 JavaMain + 805 8 java
0x0000000107d7d59c -[JavaLaunchHelper launchJava:] + 42 9
com.apple.Foundation 0x00007fff8e2e1d00 __NSThreadPerformPerform + 293 10 com.apple.CoreFoundation 0x00007fff878cea01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17 11 com.apple.CoreFoundation 0x00007fff878c0b8d __CFRunLoopDoSources0 + 269 12 com.apple.CoreFoundation 0x00007fff878c01bf __CFRunLoopRun + 927 13 com.apple.CoreFoundation 0x00007fff878bfbd8 CFRunLoopRunSpecific + 296 14 java
0x0000000107d7e463 CreateExecutionEnvironment + 871 15 java
0x0000000107d7a1ac JLI_Launch + 1952 16 java
0x0000000107d804c0 main + 101 17 java
0x0000000107d79a04 start + 52

Thread 1: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 com.apple.Foundation 0x00007fff8e28df08 -[NSCondition wait] + 237 2 com.apple.Foundation 0x00007fff8e27ed9e -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 823 3
com.apple.Foundation 0x00007fff8e27e9e9 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 131 4 java 0x0000000107d7d7b5 JVMInit + 251 5 java
0x0000000107d7acf1 JLI_Launch + 4837 6 java
0x0000000107d804c0 main + 101 7 java
0x0000000107d7e0f5 apple_main + 92 8 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 9 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 10 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 2:: Dispatch queue: com.apple.libdispatch-manager 0
libsystem_kernel.dylib 0x00007fff8a579232 kevent64 + 10 1
libdispatch.dylib 0x00007fff8f674a6a _dispatch_mgr_thread + 52

Thread 3: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 5 libjvm.dylib
0x0000000108a6b1a6 GCTaskManager::get_task(unsigned int) + 56 6
libjvm.dylib 0x0000000108a6bf85 GCTaskThread::run() + 349 7 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 8 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 9 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 10 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 4: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 5 libjvm.dylib
0x0000000108a6b1a6 GCTaskManager::get_task(unsigned int) + 56 6
libjvm.dylib 0x0000000108a6bf85 GCTaskThread::run() + 349 7 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 8 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 9 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 10 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 5: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 5 libjvm.dylib
0x0000000108a6b1a6 GCTaskManager::get_task(unsigned int) + 56 6
libjvm.dylib 0x0000000108a6bf85 GCTaskThread::run() + 349 7 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 8 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 9 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 10 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 6: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 5 libjvm.dylib
0x0000000108a6b1a6 GCTaskManager::get_task(unsigned int) + 56 6
libjvm.dylib 0x0000000108a6bf85 GCTaskThread::run() + 349 7 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 8 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 9 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 10 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 7: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6b69e os::PlatformEvent::park(long) + 404 2
libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 3 libjvm.dylib
0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 4
libjvm.dylib 0x0000000108d9486a VMThread::loop() + 444 5 libjvm.dylib 0x0000000108d942f5 VMThread::run() + 121 6 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 7
libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 8 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 9 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 8:: Java: Reference Handler 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c62952 ObjectMonitor::wait(long, bool, Thread*) + 748 3
libjvm.dylib 0x0000000108d17978 ObjectSynchronizer::wait(Handle, long, Thread*) + 202 4 libjvm.dylib 0x0000000108b39a16 JVM_MonitorWait + 156 5 ???
0x000000010977e954 0 + 4453820756 6 ???
0x0000000109770c4d 0 + 4453764173 7 ???
0x0000000109770c4d 0 + 4453764173 8 ???
0x00000001097697a7 0 + 4453734311 9 libjvm.dylib
0x0000000108ae01e2 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710 10 libjvm.dylib
0x0000000108ae0970 JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*, Symbol*, JavaCallArguments*, Thread*) + 356 11 libjvm.dylib 0x0000000108ae0b1c JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle, Symbol*, Symbol*, Thread*) + 74 12 libjvm.dylib
0x0000000108b3305d thread_entry(JavaThread*, Thread*) + 124 13 libjvm.dylib 0x0000000108d49a6f JavaThread::thread_main_inner() + 155 14 libjvm.dylib
0x0000000108d4b160 JavaThread::run() + 450 15 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 16 libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 17 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 18 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 9:: Java: Finalizer 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c62952 ObjectMonitor::wait(long, bool, Thread*) + 748 3
libjvm.dylib 0x0000000108d17978 ObjectSynchronizer::wait(Handle, long, Thread*) + 202 4 libjvm.dylib 0x0000000108b39a16 JVM_MonitorWait + 156 5 ???
0x000000010977e954 0 + 4453820756 6 ???
0x0000000109770c4d 0 + 4453764173 7 ???
0x00000001097709d0 0 + 4453763536 8 ???
0x00000001097709d0 0 + 4453763536 9 ???
0x00000001097697a7 0 + 4453734311 10 libjvm.dylib
0x0000000108ae01e2 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710 11 libjvm.dylib
0x0000000108ae0970 JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*, Symbol*, JavaCallArguments*, Thread*) + 356 12 libjvm.dylib 0x0000000108ae0b1c JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle, Symbol*, Symbol*, Thread*) + 74 13 libjvm.dylib
0x0000000108b3305d thread_entry(JavaThread*, Thread*) + 124 14 libjvm.dylib 0x0000000108d49a6f JavaThread::thread_main_inner() + 155 15 libjvm.dylib
0x0000000108d4b160 JavaThread::run() + 450 16 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 17 libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 18 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 19 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 10: 0 libsystem_kernel.dylib 0x00007fff8a57894a __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8a4b640d start_wqthread + 13

Thread 11: 0 libsystem_kernel.dylib 0x00007fff8a57894a __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8a4b640d start_wqthread + 13

Thread 12: 0 libsystem_kernel.dylib 0x00007fff8a57894a __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8a4b640d start_wqthread + 13

Thread 13: 0 libsystem_kernel.dylib 0x00007fff8a57894a __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8a4b640d start_wqthread + 13

Thread 14:: Java: Signal Dispatcher 0 libsystem_kernel.dylib
0x00007fff8a57351a semaphore_wait_trap + 10 1 libjvm.dylib
0x0000000108c6cd04 check_pending_signals(bool) + 128 2 libjvm.dylib 0x0000000108c69845 signal_thread_entry(JavaThread*, Thread*) + 57 3
libjvm.dylib 0x0000000108d49a6f JavaThread::thread_main_inner() + 155 4 libjvm.dylib
0x0000000108d4b160 JavaThread::run() + 450 5 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 6
libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 8 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 15:: Java: C2 CompilerThread0 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6b69e os::PlatformEvent::park(long) + 404 2
libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 3 libjvm.dylib
0x0000000108c48faa Monitor::wait(bool, long, bool) + 222 4
libjvm.dylib 0x00000001089b24b2 CompileQueue::get() + 122 5 libjvm.dylib 0x00000001089b26d4 CompileBroker::compiler_thread_loop() + 376 6 libjvm.dylib
0x0000000108d49a6f JavaThread::thread_main_inner() + 155 7
libjvm.dylib 0x0000000108d4b160 JavaThread::run() + 450 8 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 9 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 10 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 11 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 16:: Java: C2 CompilerThread1 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6b69e os::PlatformEvent::park(long) + 404 2
libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 3 libjvm.dylib
0x0000000108c48faa Monitor::wait(bool, long, bool) + 222 4
libjvm.dylib 0x00000001089b24b2 CompileQueue::get() + 122 5 libjvm.dylib 0x00000001089b26d4 CompileBroker::compiler_thread_loop() + 376 6 libjvm.dylib
0x0000000108d49a6f JavaThread::thread_main_inner() + 155 7
libjvm.dylib 0x0000000108d4b160 JavaThread::run() + 450 8 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 9 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 10 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 11 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 17:: Java: C1 CompilerThread2 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6b69e os::PlatformEvent::park(long) + 404 2
libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 3 libjvm.dylib
0x0000000108c48faa Monitor::wait(bool, long, bool) + 222 4
libjvm.dylib 0x00000001089b24b2 CompileQueue::get() + 122 5 libjvm.dylib 0x00000001089b26d4 CompileBroker::compiler_thread_loop() + 376 6 libjvm.dylib
0x0000000108d49a6f JavaThread::thread_main_inner() + 155 7
libjvm.dylib 0x0000000108d4b160 JavaThread::run() + 450 8 libjvm.dylib 0x0000000108c6e99e java_start(Thread*) + 246 9 libsystem_pthread.dylib
0x00007fff8a4b8268 _pthread_body + 131 10 libsystem_pthread.dylib
0x00007fff8a4b81e5 _pthread_start + 176 11 libsystem_pthread.dylib
0x00007fff8a4b641d thread_start + 13

Thread 18:: Java: Service Thread 0 libsystem_kernel.dylib
0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib
0x0000000108c6a7b4 os::PlatformEvent::park() + 192 2 libjvm.dylib
0x0000000108c48504 ParkCommon(ParkEvent*, long) + 42 3 libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 4
libjvm.dylib 0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 5 libjvm.dylib
0x0000000108cc3b36 ServiceThread::service_thread_entry(JavaThread*, Thread*) + 132 6 libjvm.dylib 0x0000000108d49a6f JavaThread::thread_main_inner() + 155 7 libjvm.dylib
0x0000000108d4b160 JavaThread::run() + 450 8 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 9
libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 10 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 11 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 19: 0 libsystem_kernel.dylib 0x00007fff8a578136 __psynch_cvwait + 10 1 libjvm.dylib 0x0000000108c6b69e os::PlatformEvent::park(long) + 404 2
libjvm.dylib 0x0000000108c48dda Monitor::IWait(Thread*, long) + 168 3 libjvm.dylib
0x0000000108c49043 Monitor::wait(bool, long, bool) + 375 4
libjvm.dylib 0x0000000108d49f42 WatcherThread::sleep() const + 126 5 libjvm.dylib
0x0000000108d4add5 WatcherThread::run() + 243 6 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 7
libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 8 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 9 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 20 Crashed:: Java: Game 0 libsystem_kernel.dylib
0x00007fff8a578286 __pthread_kill + 10 1 libsystem_c.dylib
0x00007fff91eecb53 abort + 129 2 libc++abi.dylib
0x00007fff8a8fda21 abort_message + 257 3 libc++abi.dylib
0x00007fff8a9259d1 default_terminate_handler() + 267 4
libobjc.A.dylib 0x00007fff89d8a7d6 _objc_terminate() + 103 5 libc++abi.dylib 0x00007fff8a9230a1 std::__terminate(void ()()) + 8 6 libc++abi.dylib
0x00007fff8a922b30 __cxa_throw + 121 7 libobjc.A.dylib
0x00007fff89d86898 objc_exception_throw + 341 8
com.apple.CoreFoundation 0x00007fff879b1e1a +[NSException raise:format:arguments:] + 106 9 com.apple.Foundation
0x00007fff8e3178cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 10 com.apple.Foundation 0x00007fff8e29957f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156 11 com.apple.AppKit 0x00007fff87f51c41 -[NSApplication run] + 928 12 liblwjgl.dylib 0x0000000121828a2e _glfwPlatformCreateWindow + 1406 13 liblwjgl.dylib 0x0000000121824d9b glfwCreateWindow + 443 14 ???
0x000000010977e954 0 + 4453820756 15 ???
0x0000000109770760 0 + 4453762912 16 ???
0x0000000109770760 0 + 4453762912 17 ???
0x0000000109770c4d 0 + 4453764173 18 ???
0x0000000109770c92 0 + 4453764242 19 ???
0x00000001097697a7 0 + 4453734311 20 libjvm.dylib
0x0000000108ae01e2 JavaCalls::call_helper(JavaValue
, methodHandle*, JavaCallArguments*, Thread*) + 1710 21 libjvm.dylib
0x0000000108ae0970 JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*, Symbol*, JavaCallArguments*, Thread*) + 356 22 libjvm.dylib 0x0000000108ae0b1c JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle, Symbol*, Symbol*, Thread*) + 74 23 libjvm.dylib
0x0000000108b3305d thread_entry(JavaThread*, Thread*) + 124 24 libjvm.dylib 0x0000000108d49a6f JavaThread::thread_main_inner() + 155 25 libjvm.dylib
0x0000000108d4b160 JavaThread::run() + 450 26 libjvm.dylib
0x0000000108c6e99e java_start(Thread*) + 246 27 libsystem_pthread.dylib 0x00007fff8a4b8268 _pthread_body + 131 28 libsystem_pthread.dylib 0x00007fff8a4b81e5 _pthread_start + 176 29 libsystem_pthread.dylib 0x00007fff8a4b641d thread_start + 13

Thread 20 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x0000000000000006 rcx: 0x00000001217b7c58 rdx: 0x0000000000000000 rdi: 0x0000000000004903 rsi: 0x0000000000000006 rbp: 0x00000001217b7c80 rsp: 0x00000001217b7c58
r8: 0x6e6f697470656378 r9: 0x00007fff91f16d70 r10: 0x0000000008000000 r11: 0x0000000000000206 r12: 0x00000001217b7de0 r13: 0x00007fe7c0d223f0 r14: 0x00000001217ba000 r15: 0x00000001217b7cc0 rip: 0x00007fff8a578286 rfl: 0x0000000000000206 cr2: 0x00007fff7722bfd8 Logical CPU: 0 Error Code:
0x02000148 Trap Number: 133

Community
  • 1
  • 1
Vi Pie
  • 1
  • 1
  • 2

3 Answers3

1

It seems that you are making another Main class with new Main().start();

Since you're in the main, maybe try this.start();

Also, if this don't solve your problem, try to make a second class containing all your Thread stuff and then do: new MyThreadClass.start(); in your main.

JFPicard
  • 5,029
  • 3
  • 19
  • 43
  • Thank you, I tried your solutions but they didn't work. The first because you can't use this in a static function (the main) and the second one just leads me to the same error. – Vi Pie Aug 07 '15 at 09:10
  • It seems the thread that should be the first is the 20, the one that crashed from the report I posted above! @Sid – Vi Pie Aug 07 '15 at 09:22
0

Are you sure you've gotten the flag correct ? At one location you say

-XstartOnFirstThread but then you supply -XstartOnThread argument. It might just be a typo but this is apparently a known issue on Mac.

Community
  • 1
  • 1
Sid
  • 465
  • 6
  • 14
  • Sorry, it was a typo, but I wrote it correctly on Eclipse. The problem is that the flag is set but it doesn't work. I've both toggled the button you find in "run>run config. > etc." and types by hand the string. I know there's a issue, but I can't get it to work! – Vi Pie Aug 07 '15 at 09:15
0

the flag dose normally work, there are peoples Extensive directions findable with a lot of google-fu for tracking down the exact pid of the exact thread running on your machine and checking to see if the flag is set. But as i am doing the same toutorial you are I have what you really want instead. Code that compiles...... (i have left as many comments in as possible , its a bastard compiltation of many peoples Lwjgl3 getting started toutorials....giving credit back as a great thankyou for them helping me smack OSX straight.....happy bird flapping.....which is by far one of the best totourials out on Lwjgl3.....[C]herno....love the work

package bird;

import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;

import org.lwjgl.Version;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;





public class Main  {


    private static final int WIDTH = 1280;
    private static final int HEIGHT = 720;

    private static GLFWErrorCallback errorCallback;
    private static GLFWKeyCallback   keyCallback;

    private long window;

    private Thread thread;
    private boolean isRunning = false;



   /* public void start() {

        thread = new Thread(this, "Game");
        thread.start();

    }
    */





    public void run() {
        isRunning = true;

        System.out.println("Flappy " + Version.getVersion() + "!");

        try {
            init();
            loop();

            // Destroy window and window callbacks
            glfwDestroyWindow(window);
        } finally {
            // Terminate GLFW and free the GLFWErrorCallback
            glfwTerminate();
        }
    }

    private void init() {



        // Setup an error callback. The default implementation
        // will print the error message in System.err.
        glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));

        // Initialize GLFW. Most GLFW functions will not work before doing this.
        if ( glfwInit() != GLFW_TRUE )
            throw new IllegalStateException("Unable to initialize GLFW");

        // Configure our window
        glfwDefaultWindowHints(); // optional, the current window hints are already the default
        glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
        glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable



        // Create the window
        window = glfwCreateWindow(WIDTH, HEIGHT, "Flapping the bird!", NULL, NULL);
        if ( window == NULL )
            throw new RuntimeException("Failed to create the GLFW window, GL_ -F-_U-");



        // Get the resolution of the primary monitor
        GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
        // Center our window
        glfwSetWindowPos(
            window,
            (vidmode.width() - WIDTH) / 2,
            (vidmode.height() - HEIGHT) / 2
        );

        glfwSetKeyCallback(window, new KeyboardInput());

        // Make the OpenGL context current
        glfwMakeContextCurrent(window);
        // Enable v-sync
        glfwSwapInterval(1);

        // Make the window visible
        glfwShowWindow(window);

        GL.createCapabilities();

        glfwInit();


    }


    private void loop() {
        // This line is critical for LWJGL's interoperation with GLFW's
        // OpenGL context, or any context that is managed externally.
        // LWJGL detects the context that is current in the current thread,
        // creates the GLCapabilities instance and makes the OpenGL
        // bindings available for use.

        // Set the clear color




        // Run the rendering loop until the user has attempted to close
        // the window or has pressed the ESCAPE key.
        while ( glfwWindowShouldClose(window) == GLFW_FALSE && isRunning == true) {

            update();
            render();


        }
    }

    public void update() {
         glfwPollEvents();

         if (KeyboardInput.keys[GLFW_KEY_ESCAPE]) {
             glfwSetWindowShouldClose(window, GLFW_TRUE);
         }
         if (KeyboardInput.keys[GLFW_KEY_SPACE]) {
             System.out.println("Farfenugen");
         }    
    }


    public void render() {
        glfwSwapBuffers(window); 
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    }

    public static void main(String[] args) {
        new Main().run();
        }



}