首页 \ 问答 \ 服务中的多线程(Android / Java)(Multithreading in a Service (Android/Java))

服务中的多线程(Android / Java)(Multithreading in a Service (Android/Java))

我的应用程序需要经常需要下载图像。 所以我正在实施一个IntentService来提供下载请求。

第一个问题是IntentService按顺序和按顺序提供下载服务,我希望有一种方法可以优先考虑下载并同时进行多次下载。

顺便说一下,我正在考虑使用(在IntentService内部)一个带有PriorityBlockingQueue的ThreadPoolExecutor,或者组合一个PriorityBlockingQueue和AsyncTasks。

解决这个问题的最佳方法是什么? 还有其他一些合理的可行性吗?

提前致谢


My app needs frequently needs to download images. So i'm implementing an IntentService in order to serve the download petitions.

The first problem is that the IntentService serves the download in order and sequentially and I'd like to have a way of prioritizing the downloads and making multiple downloads at the same time.

By the way I'm considering to use (inside the IntentService) a ThreadPoolExecutor with an PriorityBlockingQueue or combine a PriorityBlockingQueue and AsyncTasks.

What is the best approach for this problem? Is there some other reasonable posibilities?

Thanks in advance


原文:https://stackoverflow.com/questions/12033642
更新时间:2023-02-11 20:02

最满意答案

首先,您将模型类名称传递给StoreManager.lookup调用,而不是商店类名称:

store:  Ext.data.StoreManager.lookup('Proyecto.model.MD_PJdatos')

然后,即使您传递了商店类名称,它仍然无法工作,因为StoreManager.lookup需要“商店的ID,商店实例或商店配置”,而不是商店类名称。

只需简单地替换StoreManager.lookup调用:

new Proyecto.store.ST_PJdatos

First of all, you are passing the model class name to your StoreManager.lookup call, not the store class name:

store:  Ext.data.StoreManager.lookup('Proyecto.model.MD_PJdatos')

Then, even if you passed the store class name it would still not work because StoreManager.lookup expects "The id of the Store, or a Store instance, or a store configuration" but not a store class name.

Replace your StoreManager.lookup call with simply:

new Proyecto.store.ST_PJdatos

相关问答

更多
  • 可以使用xindex,xcount和父变量。 我通过分析源找到它,您可能无法在API中找到有关此解决方案的任何其他信息。 示例模板: '', '', '
    ', '{src} ', '
    在单独的IEnumerable中创建第一个过滤器,然后使用它来创建两个数据视图: var filtered = dt.AsEnumerable() .Where(r => r.Field("ID") < 1000); DataView dv1 = filtered.AsDataView(); DataView dv2 = filtered.Where(r => r.Field("Salary") > 50000) ...
  • 首先,您将模型类名称传递给StoreManager.lookup调用,而不是商店类名称: store: Ext.data.StoreManager.lookup('Proyecto.model.MD_PJdatos') 然后,即使您传递了商店类名称,它仍然无法工作,因为StoreManager.lookup需要“商店的ID,商店实例或商店配置”,而不是商店类名称。 只需简单地替换StoreManager.lookup调用: new Proyecto.store.ST_PJdatos First of ...
  • 通过它的外观,您没有正确返回successProperty值。 更改您的PHP代码的响应,如下所示。 您商店中JsonReader的默认successProperty是“成功”。 ExtJs将在您的服务器响应中查找此属性。 http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.JsonReader-cfg-successProperty 此外,您可能希望将数据作为json数组返回,而不是对象。 你不需要数据数组中的图像对象。 服务器响应: { "data":[{ ...
  • 您可以检查事件对象的属性,如shiftKey , ctrlKey , altKey等。所以它会是这样的(未经测试): myDataView.on('contextmenu', function(dv, idx, node, e){ if(e.shiftKey){ // shift is pressed } }); You can check the event object for properties like shiftKey, ctrlKey, altKey, etc ...
  • 做一件事,创建一个包含字段“size”,“report_data”和“position”的商店。 var store = new Ext.data.JsonStore({ id : 'panel_store', fields : ['size', 'position', 'report_data'] }); 为每个报告创建一个模板(这里可以添加一些其他数据): var template = new Ext.XTemplate( '
    Sencha Architect不支持所有功能,但它有很多限制。 请按照以下步骤自定义prepareData。 1 - 在项目检查器中,单击“数据视图” 2 - 在配置面板中,选择“Process Config”并单击旁边的+号。 3 - 将创建一个流程方法,单击此方法并转到代码编辑器 4 - 将其添加到代码编辑器中 return Ext.apply(config, { prepareData : function ( data, recordIndex, record ) { // ...
  • 您必须使用store而不是data dataview : { xtype: 'dataview', scrollable: true, itemSelector: 'tr', store: { data:[{ selCodeType: 'selCodeType', ...
  • (第一:'MyStore'可能不是字符串,而是对真实ExtJS数据存储的引用。您可能不需要引号) 数据存储包含某些模型的项目列表。 您可以在模板中读取该模型的字段,方法是将字段名称放在accolades {}之间。 假设模型带有'url'字段,模板将变为: var imageTpl = new Ext.XTemplate( '', '
    ', '
    回答问题的第二部分: 在按钮处理程序中,您需要获取视图的选择模型,并从中获取有关所选记录的信息: handler: function(nodes) { // find view component var view = dataView_player.down('dataview'); // get all selected records var records = view.getSelectionModel().getSelection(); // ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)