We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › Multi-Thread Serial Out Commands?
Page Index Toggle Pages: 1
Multi-Thread Serial Out Commands??? (Read 785 times)
Multi-Thread Serial Out Commands???
Dec 5th, 2009, 3:48pm
 
I have a interactive game being controlled by devices over the serial port. I am running a counter using the main draw() loop and setting variables in singleton classes using the input from the hardware devices over serial. The problem is that when I am sending data over serial you notice the counter stop while the data is being transferred. I have tried various methods of implementing threads to handle the I/O but am having no luck... is I/O excluded from multi threading?

I have an example I am trying to get working withing the context of my game... maybe someone can point out an error or offer some advice.

*** This is the test class I am calling that does output to the console

public class TestThread implements Runnable{

    public void run() {
          // TODO Auto-generated method stub
    }
    public TestThread(int num){
          for(int i = 0; i< num ; i++){
                System.out.println("INSIDE THREAD" + i);
          }
    }
}//end class

*** I am calling it by doing the following once from my main draw() loop. The main draw loop freezes while the "thread" finishes its output to the console.

 Runnable runnable = new TestThread(10000000);
 Thread thread = new Thread(runnable);
 thread.start();

Any help would be greatly appreciated.

Page Index Toggle Pages: 1