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 & HelpSyntax Questions › Creating a new thread
Page Index Toggle Pages: 1
Creating a new thread (Read 442 times)
Creating a new thread
Apr 17th, 2006, 8:36pm
 
Hi,
I would like to create a new thread in processing that has the following functions:
void connect() //connects to a MySQL database
bool connected() //true=connected successfully
int getp(int ID1, int ID2) //gets some data based on the parameters
void getp(int ID1, int ID2, int v) //sets some data based on the parameters
void update() //is automatically called every 1/4 second in a separate thread and reads/writes to the database

I have all the functions working, but I'm not sure how to do the threading..

anyone?
Thanks!
Re: Creating a new thread
Reply #1 - Apr 17th, 2006, 11:18pm
 
You need to build these functions into a class, that implements "runnable" or extends "Thread".

I wrote a threaded image loader that runs in a seperate thread here: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1141752225;start=6#6

It should be fairly trivial to swap your functions into it, and get it to work as you want.
Page Index Toggle Pages: 1