Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread not starting after calling Java method from C  RSS feed

Eric Kis
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

So I'm having some trouble with my code. It works, but not in the way I want it to work. Here is the scenario:

A user clicks (CTRL+1). My C-code will register this sequence and pass a variable to a Java method. [Note: I needed to use C here since my program is designed to run while a full-screen game is running as well. Java would not be able to register the key-events without focus.] The Java method will start a new Thread which will count down. Once a certain amount of time has elapsed, the Java Thread will play a sound clip to the user.

This all works. The problem is, I want to be able to start multiple Threads (not at the same time, though). So, while one Thread could be counting down, another one or two or three could also be counting down. I can get one thread to start, but no new threads will start until the first one is complete. In fact, no key sequences are even registered once a Thread has been started. Following is the C code and partial Java code.


startJava.c (starts new thread)

Here's the actual run()
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!