Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. [code]type test
    
  2.     foo As Integer
    
  3.     Declare Sub main()
    
  4.     Declare Sub thread
    
  5. End Type
    
  6. 
    
  7. Sub test.thread()
    
  8.     Do
    
  9.         This.foo += 1
    
  10.         Print Timer() & ":" & Str(This.foo)
    
  11.         Sleep 1000
    
  12.     Loop
    
  13. End Sub
    
  14. 
    
  15. Sub test.main()
    
  16.     threadcall thread()
    
  17. End Sub
    
  18. 
    
  19. Dim foo As test Ptr = Callocate(Sizeof(test))
    
  20. foo->main()
    
  21. Sleep 4000, 1
    
  22. Deallocate(foo)
    
  23. 
    
  24. 
    
  25. Do
    
  26.     Sleep 1, 1
    
  27. Loop
    
  28. 'dim bar as sub() 
    
  29. 'bar = foo.thread
    
  30. [/code]
    
  31. [pre]tpm@lara:/media/data20_md0/Projekte/freeBASIC/test/test4$ ../../sonstiges/fbc_static/FreeBASIC-0.24.0-linux-staticbin/bin/fbc test4.bas && ./test4
    
  32. 1362174784.144476:1
    
  33. 1362174785.184758:2
    
  34. 1362174786.224755:3
    
  35. 1362174787.263767:4
    
  36. 1362174788.303786:1
    
  37. 1362174789.344021:2
    
  38. 1362174790.383774:3
    
  39. 1362174791.424802:4
    
  40. 1362174792.464761:5
    
  41. 1362174793.504418:6
    
  42. 1362174794.544829:7
    
  43. 
    
  44. tpm@lara:/media/data20_md0/Projekte/freeBASIC/test/test4$       
    
  45. [/pre]