在blakcberry实现单态

本文介绍了一种使用RuntimeStore实现单例模式的方法,该方法确保在整个应用程序或跨多个应用程序中只存在一个实例,并提供全局访问点。文中通过示例代码详细解释了其实现过程。

按传统j2se的写法折腾了n久都不行,终于发现了一个官方例子:

 

 

Details

An application may require one or more singleton objects to be accessed from within the application itself or by other applications. The static variable ‘_instance’, in the sample below, is initialized to null for each process running on the system. Therefore, the getInstance() method needs to check the ‘_instance’ variable each time it is invoked.

To create a singleton using the RuntimeStore, use the following sample:

import net.rim.device.api.system.*;

class MySingleton {
   private static MySingleton _instance;
   private static final long GUID = 0xab4dd61c5d004c18L;

   // constructor
   MySingleton() {}

   public static MySingleton getInstance() {
      if (_instance == null) {
         _instance = (MySingleton)RuntimeStore.getRuntimeStore().get(GUID);
      if (_instance == null) {

         MySingleton singleton = new MySingleton();

         RuntimeStore.getRuntimeStore().put(GUID, singleton);
         _instance = singleton;
         }
      }

      return _instance;

   }
}

Use Cases

A singleton based on the above sample code might be used in the following scenarios:

    • A network manager class that handles all network-related requests for an application
    • A packet/message sender class
    • A debugging/logging class
【电力系统】采用有源电力滤波器抑制谐波研究(Simulink仿真实现)内容概要:本文围绕电力系统中谐波抑制问题展开,重点研究采用有源电力滤波器(APF)进行谐波治理的方法,并通过Simulink搭建仿真模型验证其有效性。文中介绍了有源电力滤波器的工作原理,特别是基于同步旋转坐标系(SRF)算法的电流检测方法,实现对负载谐波电流的实时跟踪与补偿。仿真结果表明,该方法能够有效降低电网中的谐波含量,提升电能质量。此外,文档还提及多种相关电力系统仿真研究案例,涵盖微电网优化、无功补偿、储能配置等领域,体现出较强的技术综合性与工程应用背景。; 适合人群:具备电力系统基础知识和MATLAB/Simulink仿真能力的电气工程专业学生、研究人员及从事电能质量治理相关工作的工程技术人员。; 使用场景及目标:①掌握有源电力滤波器的基本结构与控制策略;②学习基于SRF算法的谐波电流检测方法;③利用Simulink构建APF仿真系统并分析其滤波性能;④为电能质量控制、电力电子装置设计等课题提供技术参考与实现思路。; 阅读建议:建议结合文中提到的Simulink仿真模型进行实践操作,重点关注SRF算法模块与电流控制环的设计细节,同时可参考提供的网盘资源获取完整代码与模型文件,便于复现实验结果并进一步拓展研究。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值