MIDlet 作为单例
将 MIDlet
类实现为单例是否安全?也就是说,毕竟 Display 类的行为就像每个 midlet 的单例,那么 midlet 本身的行为是否也是单例,这样实现它就不会破坏某些东西?
换句话说,一个应用程序不可能同时运行两个实例,不是吗?我的意思是,AMS 不会允许这样做,不是吗?
谢谢!
Is it safe to implement a MIDlet
class as a singleton? That is, after all, the Display class is acting like a singleton for each and every midlet so is the midlet itself a singleton by behaviour so that implementing it as such wouldn't break something?
In other words, it is not possible to have two instances of an app running, is it? I mean, the AMS wouldn't allow it, would it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,Singleton 类具有受保护的构造函数,这会导致问题,因为 AMS 需要 MIDlet 类构造函数是公共的,而不是受保护的或私有的。
Normally Singleton classes have protected constructor, and this will cause a problem because the AMS needs the MIDlet class constructor to be public not protected nor private.