How to do multi-threading ?
- From: Ionut Borcoman at debian <borco mailbox ro>
- To: "gtk-list redhat com" <gtk-list redhat com>
- Subject: How to do multi-threading ?
- Date: Sun, 21 Jun 1998 16:15:40 +0000
Hi,
I need something like this :
1. An aplication with a START and STOP button.
2. The START should set a variable to TRUE (running = TRUE) and call a
function with an infinite loop like:
void infiniteLoop()
{
	while(running){
		/* do something */
	}
}
3. The STOP should set the variable FALSE so that to force the
infiniteLoop to finish.
I have try to set callbacks to START and STOP buttons, but the
infiniteLoop doesn't let other signals to be emitted. 
I have done something like this:
main()
{
....
  gtk_signal_connect (GTK_OBJECT (startButton), "clicked", 
		      GTK_SIGNAL_FUNC(startButton_clicked_event), NULL);
  gtk_signal_connect (GTK_OBJECT (stopButton), "clicked", 
		      GTK_SIGNAL_FUNC(stopButton_clicked_event), NULL);
....
}
void startButton_clicked_event (GtkWidget *widget, gpointer data)
{
  running = true;
  infiniteLoop();
}
void stopButton_clicked_event (GtkWidget *widget, gpointer data)
{
  running = false;
}
I have try to use <pthread.h> but I get sigsegs and I find no docs or
examples on how to use the threads in Linux.
Any ideea will be higly apreciated. 8-)
Please answer me.
TIA,
Ionutz
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]