?? form1.frm
字號(hào):
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 375
Left = 6360
TabIndex = 12
Top = 3720
Width = 495
End
Begin VB.Label labmutex
BackColor = &H00FFC0FF&
BackStyle = 0 'Transparent
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 6360
TabIndex = 11
Top = 3000
Width = 495
End
Begin VB.Label labelshow
BackColor = &H0080C0FF&
BackStyle = 0 'Transparent
BeginProperty Font
Name = "幼圓"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 615
Left = 2880
TabIndex = 10
Top = 6480
Width = 6135
End
Begin VB.Label Label4
BackColor = &H00FFC0FF&
BackStyle = 0 'Transparent
Caption = "empty="
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5280
TabIndex = 9
Top = 4320
Width = 1095
End
Begin VB.Label Label3
BackColor = &H00FFC0FF&
BackStyle = 0 'Transparent
Caption = "full ="
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5280
TabIndex = 8
Top = 3720
Width = 1215
End
Begin VB.Label Label2
BackColor = &H00FFC0FF&
BackStyle = 0 'Transparent
Caption = "mutex="
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5280
TabIndex = 7
Top = 3000
Width = 1215
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 7
Left = 8040
TabIndex = 6
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 6
Left = 6855
TabIndex = 5
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 5
Left = 5760
TabIndex = 4
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 4
Left = 4560
TabIndex = 3
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 3
Left = 3360
TabIndex = 2
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Height = 975
Index = 2
Left = 2145
TabIndex = 1
Top = 1560
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
ForeColor = &H00000000&
Height = 975
Index = 1
Left = 960
TabIndex = 0
Top = 1560
Width = 975
End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mutex As Integer
Dim full As Integer
Dim emputy As Integer
Dim count1 As Integer
Dim i As Integer
Dim bool1 As Boolean
Dim bool As Boolean
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
If bool1 Then
Label7.Visible = True
Label8.Visible = True
bool1 = False
Else
Label7.Visible = False
Label8.Visible = False
bool1 = True
End If
End Sub
Private Sub consumer_Click()
If full > 0 Then
If mutex = 1 Then
mutex = 0
labmutex.Caption = "0"
timer_consumer.Enabled = True
Else: MsgBox "緩沖區(qū)正被占用,請(qǐng)等待............... ", 5 + vbExclamation, "信息提示"
End If
Else: MsgBox "已無(wú)可用緩沖區(qū)供消費(fèi)!", 5 + vbExclamation, "信息提示"
End If
End Sub
Private Sub Form_Load()
mutex = 1
full = 0
emputy = 7
count1 = 0
i = 0
Form2.Hide
End Sub
Private Sub producer_Click()
count1 = count1 + 1
If emputy > 0 Then
If mutex = 1 Then
mutex = 0
labmutex.Caption = "0"
timer_production.Enabled = True
Else:
count1 = count1 - 1
MsgBox "緩沖區(qū)正被占用,請(qǐng)等待...............", 7 + vbExclamation, "信息提示"
'count1 = count1 - 1
End If
Else: MsgBox "已無(wú)可用緩沖區(qū)供存入!", 7 + vbExclamation, "信息提示"
count1 = count1 - 1
End If
End Sub
Private Sub timer_production_Timer()
If bool Then
Picture1(count1).Visible = True
labelshow.Caption = "生產(chǎn)者進(jìn)程正在占用緩沖區(qū),請(qǐng)等待..............."
bool = False
Else
Picture1(count1).Visible = False
labelshow.Caption = "生產(chǎn)者進(jìn)程正在占用緩沖區(qū),請(qǐng)等待..............."
bool = True
End If
i = i + 1
If i = 7 Then
i = 0
timer_production.Enabled = False
mutex = 1
labmutex.Caption = "1"
Picture1(count1).Visible = True
full = full + 1
labfull.Caption = Str(full)
emputy = emputy - 1
labemputy.Caption = Str(emputy)
labelshow.Caption = " Ready "
End If
End Sub
Private Sub timer_consumer_timer()
If bool Then
Label1(count1).BackColor = &HFF00&
labelshow.Caption = "消費(fèi)者進(jìn)程正在占用緩沖區(qū),請(qǐng)等待..............."
bool = False
Else
Label1(count1).BackColor = &H8000000F
Picture1(count1).Visible = False
labelshow.Caption = "消費(fèi)者進(jìn)程正在占用緩沖區(qū),請(qǐng)等待............... "
bool = True
End If
i = i + 1
If i = 7 Then
i = 0
timer_consumer.Enabled = False
mutex = 1
labmutex.Caption = "1"
Label1(count1).BackColor = &H8000000F
Picture1(count1).Visible = False
count1 = count1 - 1
full = full - 1
labfull.Caption = Str(full)
emputy = emputy + 1
labemputy.Caption = Str(emputy)
labelshow.Caption = " Ready "
End If
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -