小编Eya*_*ama的帖子

Parallel.For中的变量

所以我有3个嵌套for循环,内部两个做很少的工作.我想将最外层的循环转换为并行循环.

我的问题是:

如果我在循环中有一个变量,那么用作临时值持有者并在每个循环中获取一个新值.当并行性开始时,我是否需要担心该变量?

我的意思是所有线程都会覆盖相同的变量吗?

 for (int i = 0; i < persons.number; i++) //Loop all the people
    var Dates = persons[i].Appointments.bydate(DateStep);
Run Code Online (Sandbox Code Playgroud)

我是否需要担心并行循环中的Dates变量?

抱歉我的问题格式不好,但这只是我的第二个问题而且我到了那里.

c# multithreading task-parallel-library

4
推荐指数
1
解决办法
1185
查看次数

在具有两个GCM BroadcastReceivers的应用程序中偶尔出现GCM错误:INVALID_SENDER

我继承了一个已经实现了GCM服务的应用程序并且运行良好.

我说的很好,因为有一半时间,当应用程序启动时,我得到错误INVALID_SENDER而另一半我得不到它!

我得到错误的时间和我没有得到的时间之间没有区别(或者我可能错过了差异).

我不时从GCM收到消息(当我INVALID_SENDER登录后没有得到)

这是onCreate()我主要活动中的注册码

private void registerGCM() throws Exception {
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    registerReceiver(mHandleMessageReceiver, new IntentFilter(
            CommonUtilities.DISPLAY_MESSAGE_ACTION));
    final String regId = GCMRegistrar.getRegistrationId(this);
    if (regId.equals("")) {

        // Automatically registers application on startup.
        GCMRegistrar.register(this, CommonUtilities.SENDER_ID);
    } else {


        // Device is already registered on GCM, check server.
        if (GCMRegistrar.isRegisteredOnServer(this)) {


            ServerUtilities.register(mContext, regId);
        } else {
            // Try to register again, but not in the UI thread.
            // It's also necessary to cancel the thread onDestroy(),
            // …
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

2
推荐指数
1
解决办法
5391
查看次数

Microsoft TPL(任务并行库)与英特尔TBB(线程构建块)

我的问题是,正如标题所说:在一般水平上(易用性,对发生的事情的控制程度等)你会推荐哪一个小型并行程序?微软的TPL还是英特尔的TBB?

先感谢您

c# c++ multithreading tbb task-parallel-library

1
推荐指数
1
解决办法
1590
查看次数

MixPanel:在报告中显示为来宾的用户

我一直在尝试将Mixpanel集成到我的Android应用程序中.在跟踪事件等方面,事情很好,但问题是所有事件都记录在报告中的单个客户下.我在mixpanel.identify()and mixpanel.getPeople().identify()和我的代码上调用了identify(),如下所示:

    MixpanelAPI mixpanel = MixpanelAPI.getInstance(this, MIXPANEL_TOKEN);
    MixpanelAPI.People people = mixpanel.getPeople();
    people.identify("666");
    people.set("first_name", "john");
    people.set("last_name", "smith");

    JSONObject props = new JSONObject();
    try {
        props.put("Gender", "Male");
        props.put("Plan", "Premium");
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }


    mixpanel.track("Plan selected", props);
    mixpanel.flush();       
Run Code Online (Sandbox Code Playgroud)

无论跟踪事件发送了多少次(即使我更改了标识的值并再次跟踪),所有事件都会以随机客户名称进行跟踪:访客#74352

android mixpanel

1
推荐指数
1
解决办法
1068
查看次数