Przemek

Please tell me where I am mistaking.

thread static aFld := { { '', 0 } }
static mtx

proc main()
   local aThd := array( 5 )
   local i

   CLEAR SCREEN

   if ! hb_mtvm()
      ? "No MT support, quitting!"
      return nil
   endif

   mtx := hb_mutexCreate()

   for i := 1 to 5
      aThd[ i ] := hb_threadStart( @thFunc() )
   next
   
   aeval( aThd, {|hThd| hb_threadJoin( hThd ) } )
    
   return

func thFunc()
   local n
   local aFields := aFld

   hb_mutexLock( mtx )

   n := ascan( aFields, {|e| e[ 1 ] == 'ALIAS' } ) 
   if n > 0
      ? 'Oh, it must never been there as aFields is a thread static! '+str(
ThreadId(),2 )
   else
      aadd( aFields, { 'ALIAS',212 } )
   endif

   hb_mutexUnlock( mtx )

   return nil

//-------------------------------------------------------//

I assume that  "thread static" is different for each thread but above
example
suggests otherwise. It is breaking my first attempts to port my applications
to MT mode.

It took me a while to locate the problem. OR may be I need to learn 
more about file wide thread statics .

Regards
Pritpal Bedi
-- 
View this message in context: 
http://www.nabble.com/File-wide-THREAD-STATICS-%3A-behaving-differently-tp21049014p21049014.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to