VB.NET Singleton模式 单件模式
2012-09-14 12:08
337 查看
'Singleton模式
Public Class Singleton
Private Shared uniqueInstance As New Singleton
Private Sub New()
End Sub
Public Shared Function getInstance() As Singleton
If uniqueInstance Is Nothing Then
uniqueInstance = New Singleton
End If
Return uniqueInstance
End Function
End Class
Public Class Singleton
Private Shared uniqueInstance As New Singleton
Private Sub New()
End Sub
Public Shared Function getInstance() As Singleton
If uniqueInstance Is Nothing Then
uniqueInstance = New Singleton
End If
Return uniqueInstance
End Function
End Class
Public Class Singleton Private Shared _Singleton As Singleton = Nothing Private Shared _Mutex As New system.threading.Mutex '进程同步 Private Sub New() '类构造 End Sub Public Shared Function Instance() As Singleton If _Singleton Is Nothing Then 'double-checked locking _Mutex.WaitOne() Try If _Singleton Is Nothing Then _Singleton = New Singleton End If Finally _Mutex.ReleaseMutex() End Try End If Return _Singleton End Function End Class
相关文章推荐
- VB.net设计模式之单件模式(singleton)
- 设计模式与VB .net实现 桥接模式,单件模式
- 单件模式(Singleton Pattern)vb.net
- VB.NET实现Singleton模式
- VB.net实现Singleton模式
- 单件模式(Singleton)
- C#面向对象设计模式纵横谈(2):Singleton 单件(创建型模式)
- 设计模式(五):创建型模式—Singleton(单件)
- 单件模式(Singleton)
- 如何利用VB.NET提供的方法替换字符串中的某个模式
- C#面向对象设计模式纵横谈(Singleton单件)
- 设计模式六:singleton单件模式——对象创建型模式
- 2. Singleton单件(创建型模式)
- 单件模式(singleton)
- 单件模式 Singleton---Design Pattern 5
- 四种方法实现单件(Singleton)模式
- 设计模式与VB .net实现 适配器模式
- PHP 实现单件(singleton)模式
- [设计模式]SINGLETON(单件)_对象创建型模式
- Singleton单件模式的思考