悬赏园豆:10
[已关闭问题]
关闭于 2008-06-30 21:11
很搞的写了一个类似如下的代码<br><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">class</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> Singleton :Form<br> { <br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">private</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">static</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> Singleton instance; <br><br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">private</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> Singleton() { } <br><br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">public</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">static</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> Singleton Instance <br> { <br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">get</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> <br> { <br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">if</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> (instance </font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman">==</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">null</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman">) <br> { <br> instance </font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman">=</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">new</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> Singleton(); <br> } <br> </font></span><span style="color: rgb(0, 0, 255);"><font size="3" color="#000000" face="Times New Roman">return</font></span><span style="color: rgb(0, 0, 0);"><font size="3" color="#000000" face="Times New Roman"> instance; <br> } <br> } <br> } </font></span><br>点按钮数次 只启动一个 很好 <br>但只要关闭窗体再启动出现 无法访问以释放对象 <br>错在哪里? 咋整?