Multi-threaded religious memory occupation and release discussion

xiaoxiao2021-03-06  74

Public class form1 inherits system.windows.Forms.form

#Region "Windows Form Designer Generated Code"

Public Sub new () mybase.new ()

'This call is required for the Windows Form Designer. InitializeComponent ()

'Add any initialization after INITIALIZECOMPONENT ()

End Sub

'Form rewriting Dispose to clean up the list of components. Protected overloads overrides sub dispose (byval disposing as boolean) ing disponation kiln (Components Is Nothing) Then components.dispose () end if endiffs) End sub

'Windows Form Designer Supply Private Components as System.comPonentModel.icontainer

'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () '' Button1 'Me.Button1. Location = new system.drawing.point (56, 112) me.button1.name = "Button1" me.button1.tabindex = 0 me.button1.text = "Button1" '' Form1 'me.autoscalebasesize = new system.drawing .Size (6, 14) me.clientsize = new system.drawing.size (292, 273) me.name = "form1" me.text = "form1" me.ResumeLayout False)

End Sub

#End region

Private Mthtest As Threading.Thread Private I as INTEGER Private Withevents a as test

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For i = 1 To 50 a = New test a.ID = i mthTest = New Threading.Thread (AddressOf a.add) mthTest .Start () Next End Subprivate Sub K () Handles a.finish system.gc.collect () End Subend Class

Public Class Test Private Mint AS INTEGER

Public event finish ()

Public property ID () AS Integer Get Return Mint end set (byval value as integer) mint = value end vendy

Public Sub Add () DIM I as INTEGER for i = 0 to 100 Debug.Writeline ("This is the" & MintiD & "thread, running:" & i 1) Next RaiseEvent Finish () End Subend Class

转载请注明原文地址:https://www.9cbs.com/read-108954.html

New Post(0)