Click to See Complete Forum and Search --> : Why Thread function declared in a class has to be static?


mkapade
December 21st, 2004, 03:16 AM
I want to know why thread function has to be static if declared in a class. What are the advantages of making it static? or Is it just another restriction. If there any advantages then what are the advantages of declaring it global.

Andreas Masur
December 21st, 2004, 03:34 AM
The answer can be found in the following FAQ (http://www.codeguru.com/forum/showthread.php?t=312453)...

mkapade
December 21st, 2004, 05:08 AM
Thanks Andreas ! It solved my basic doubt.
But then which way one should choose, global function or static member function while creating a thread.
What is the deciding factor while choosing between them?

Andreas Masur
December 21st, 2004, 07:10 AM
Well...at the end there is no general rule...I usually follow the object-oriented principle of encapsulation, thus, my thread function usually belongs to a class (either a class on which the thread is operating or a simple thread class)....

mkapade
December 23rd, 2004, 01:49 AM
Also what is the difference between thread function and callback function? And when should we use callback function?

Andreas Masur
December 23rd, 2004, 02:26 AM
Also what is the difference between thread function and callback function? And when should we use callback function?
Basically there is not much difference...other than different naming... :cool: