10-01-2005, 05:56 PM
I am messing around with threading for something I am working on, and it works except the ouput is slightly garbled. Also depending on what delay I give the teletyping I get different results, all of which are garbled by at least 1 character. For the teletyping, the 2nd and 3rd lines are the threads and the 1st and 4th are regular called routines. Here are the different results I get and the code that I used:
This is what I get when running with Sleep 25
This is what I get when running with Sleep 100
This is what I get when running with Sleep 250
And here is the code:
This is what I get when running with Sleep 25
This is what I get when running with Sleep 100
This is what I get when running with Sleep 250
And here is the code:
Code:
declare sub thread1(byval num as integer)
declare sub thread2(byval num as integer)
declare sub teletype(text as string,x,y)
i=threadcreate (@thread1,0)
if (i = 0) then
print "Error creating thread1"
end if
ii=threadcreate (@thread2,1)
if (ii = 0) then
print "Error creating thread2"
end if
threadwait(i)
threadwait(ii)
Call teletype ("testing.................",1,1)
Call teletype ("testing again...........",10,1)
sleep
end
sub thread1 (byval num as integer)
Call teletype ("This is a test...",4,1)
end sub
sub thread2 (byval num as integer)
Call teletype ("This is another test...",7,1)
end sub
sub teletype (text as string,x,y)
text_length=len(text)
for a = 0 to text_length
temp_text$=mid$(text,a,1)
Locate x,(y+a-1):Print temp_text$
sleep 25
next
end sub