Cordova 如何在Phonegap Android和IOS应用程序中使用Phonegap后台线程

Cordova 如何在Phonegap Android和IOS应用程序中使用Phonegap后台线程,cordova,phonegap-plugins,Cordova,Phonegap Plugins,我在phonegap框架中工作。我使用两种类型的线程函数。第一个线程是调用API方法从web服务器获取消息以插入sqlite数据库,另一个线程是UI中sqlite的列表数据,这意味着我的收件箱页面。问题是由于线程继续在队列中运行而挂起设备。所以我想使用Android和ios后台线程插件。任何人都知道phonegap后台线程插件。请帮帮我 这是第一个线程函数 function itmerStart() { if (timerId) return var busy = false;

我在phonegap框架中工作。我使用两种类型的线程函数。第一个线程是调用API方法从web服务器获取消息以插入sqlite数据库,另一个线程是UI中sqlite的列表数据,这意味着我的收件箱页面。问题是由于线程继续在队列中运行而挂起设备。所以我想使用Android和ios后台线程插件。任何人都知道phonegap后台线程插件。请帮帮我

这是第一个线程函数

function itmerStart()
{
if (timerId) return
    var busy = false;
    timerId = setInterval(loadMessageListCron, 20000);

function loadMessageListCron()
{
$.ajax("http://mysamplesite.com/API/getallmessages?UserId="+ userid).done(function(data)
        {
          var i, response;
          $.each(data.messages, function (i, response)
            {
              inboxMessageItmerStop();
              insertMessages(response, i);
              inboxMessageItmerStart();
             });
         });
}
}
function inboxMessageItmerStart()
{
if (timersId) return

    timersId = setInterval(loadInboxMessageList, 5000);
var busy = false;

function loadInboxMessageList()
{
    if(!busy)
    {
        busy = true;    
    var userid = window.localStorage.getItem("userId");
    if(userid != undefined)
    {
        db.transaction(queryDB,errorCB);       
    }
        busy =  false;
    }
}  
}
这是第二个线程函数

function itmerStart()
{
if (timerId) return
    var busy = false;
    timerId = setInterval(loadMessageListCron, 20000);

function loadMessageListCron()
{
$.ajax("http://mysamplesite.com/API/getallmessages?UserId="+ userid).done(function(data)
        {
          var i, response;
          $.each(data.messages, function (i, response)
            {
              inboxMessageItmerStop();
              insertMessages(response, i);
              inboxMessageItmerStart();
             });
         });
}
}
function inboxMessageItmerStart()
{
if (timersId) return

    timersId = setInterval(loadInboxMessageList, 5000);
var busy = false;

function loadInboxMessageList()
{
    if(!busy)
    {
        busy = true;    
    var userid = window.localStorage.getItem("userId");
    if(userid != undefined)
    {
        db.transaction(queryDB,errorCB);       
    }
        busy =  false;
    }
}  
}