首页 \ 问答 \ 确定Executors.newSingleThreadExecutor()创建的线程数。执行?(Determining the number of threads created by Executors.newSingleThreadExecutor().execute?)

确定Executors.newSingleThreadExecutor()创建的线程数。执行?(Determining the number of threads created by Executors.newSingleThreadExecutor().execute?)

我有一个包含50个不同的newSingleThreadExecutor()代码实例的大型Android项目,这些实例由各种不可预测的事件触发,包括按下UI按钮。 在研究了一下之后,我认为为50个不同的代码实例中的每一个创建了一个单独的线程,并且将保持对执行程序的调用的执行顺序。

创建了多少个线程,并且在按执行程序调用的顺序维护顺序执行时出现问题?

注意:代码不使用submit,这就是为什么我对执行顺序和创建的线程数感到困惑。 例如,如果用户非常快速地按下UI按钮一百次会发生什么? 根据数据库期货何时完成,我会在不同时间完成一百个线程吗?

下面列出了在所有50个实例中如何格式化代码。

Executors.newSingleThreadExecutor().execute(new Runnable() {
    @Override
        public void run()
        { 
            // Executes multiple database calls using futures and
            // Uses get() which waits if necessary for the computation to complete, 
            // and then retrieves its result.
        }
    });

I have a large Android project with 50 distinct code instances of the newSingleThreadExecutor() that are triggered by various unpredictable events including UI button presses. After researching a bit, I think that a single thread is created for each of the 50 distinct code instances and will maintain sequential order of execution of calls to the executor.

How many threads are created and is there a problem in maintaining sequential execution in order of calls to the executor?

Note: the code is not using submit so this is why I am confused about the order of execution and number of threads created. For example, what happens if a user presses the UI button an hundred times very fast? Will I get a hundred threads finishing at different times based on when the database futures complete?

Listed below is how the code is formatted in all 50 instances.

Executors.newSingleThreadExecutor().execute(new Runnable() {
    @Override
        public void run()
        { 
            // Executes multiple database calls using futures and
            // Uses get() which waits if necessary for the computation to complete, 
            // and then retrieves its result.
        }
    });

原文:https://stackoverflow.com/questions/21418735
更新时间:2022-07-19 19:07

最新回答

数据仓库是要集成多种数据源,比如个人财务记录和购物记录,比如企业的原料、生产、销售的异构数据库。数据库一般是单一结构的,没办法集成异构源去做一个统一接口,所以在数据分析需求达到宏观规模后才弄出这么个概念来。所谓面向事务和面向主题就是这个意思。事务是数据记录查询的单一任务,主题是数据分析目标的相关数据范畴。

数据仓库是数据挖掘的对象,进行大规模的数据挖掘前先要建立数据仓库,数据挖掘的研究方向有偏向数据库的。
数据库就是我们通常用到的用于联机事务处理的。数据仓库主要针对联机分析处理帮助决策人员进行决策的。数据挖掘技术可以作为数据仓库的前端应用,在数据仓库中挖掘出有价值的信息。

相关问答

更多
  • MongoDB[1] 是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 mongoDB MongoDB[2] 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。他支持的数据结构非常松散,是类似json的bson格式,因此可以存储比较复杂的数据类型。Mongo最大的特点是他支持的查询语言非常强大,其语法有点类似于面向对象的查询语言,几乎可以实现类似关系数据库单表查询的绝大部分功能,而且还支持对数据建立索引。 h ...
  • 这很简单啊!在Windows下,假如你的MySQL装在D:\MySQL就可以这样:先切换到它的bin目录cdD:\MySQL\bin\D:\MySQL\bin>mysql-uroot-p接着输入你的root密码接下来你就可以创建数据库、创建用户、创建修改表之类的操作(常用命令如下)。查看现有数据库mysql>showdatabases;创建数据库(假如数据库名为mydb)mysql>createdatabasemydb;删除数据库(假如数据库名为mydb)mysql>dropdatabaseaccounts ...
  • 数据库 数据库(Database)是按照数据结构来组织、存储和管理数据的仓库,它产生于距今五十年前,随着信息技术和市场的发展,特别是二十世纪九十年代以后,数据管理不再仅仅是存储和管理数据,而转变成用户所需要的各种数据管理的方式。 数据库的定义:数据库(DataBase,DB)是一个长期存储在计算机内的、有组织的、有共享的、统一管理的数据集合。它是一个按数据结构来存储和管理数据的计算机软件系统。数据库的概念实际包括两层意思:  (1)数据库是一个实体,它是能够合理保管数据的“仓库”,用户在该“仓库”中存放要管 ...
  • 先百度数据仓库,在百度数据挖掘。搞清楚概念后再来具体提问。 简单来说,一个是做为数据来源,一个是对数据的处理。当然,实际应用中,没有统一的标准,很多企业乱搞,把两者混合说。
  • 去数据挖掘相关论坛 诸如www.dmresearch.net之类上去找吧
  • 大数据、数据分析、数据挖掘的区别是,大数据是互联网的海量数据挖掘,而数据挖掘更多是针对内部企业行业小众化的数据挖掘,数据分析就是进行做出针对性的分析和诊断,大数据需要分析的是趋势和发展,数据挖掘主要发现的是问题和诊断: 1、大数据(big data): 指无法在可承受的时间范围内用常规软件工具进行捕捉、管理和处理的数据集合,是需要新处理模式才能具有更强的决策力、洞察发现力和流程优化能力的海量、高增长率和多样化的信息资产; 在维克托·迈尔-舍恩伯格及肯尼斯·库克耶编写的《大数据时代》 中大数据指不用随机分析法 ...
  • 您不能将每个关系数据库系统称为数据仓库,因为数据仓库之一的主要功能是聚合来自多个数据库(具有不同模式)的数据。 它通常使用“ 星型模式 ”完成,允许组合多个维度和多个粒度。 因为NoSQL数据库系统 (基于图形或基于map-reduce)是无模式的,所以它们确实可以存储来自不同模式的数据。 此外,Map-Reduce可用于聚合具有不同粒度的数据(例如,汇总每日数据以将其与月度数据进行比较)。 You cannot call every relational database system a data wa ...
  • 数据存储(商店具有双重意义......“你可以在商店买些东西吗?”) 潘多拉(“包含所有秘密的盒子......不要打开那个盒子!请自担风险!”) Data Store (with Store having double-meaning... "can you pick up something at the Store?") Pandora ("the box containing all secrets... don't open that box! Touch at your own risk!")
  • 您无法从storedprocedures创建sqldatabase ..即使它们位于同一服务器中。我们正在处理两个不同的逻辑服务器(DW和SQLdatabase) 2.对于插入部分,您可以尝试跨数据库查询,但不支持从azureDW到SQLAzure数据库的跨数据库查询。 几个选项,我可以想一想.. 创建一个Windows应用程序,执行以下操作 1.创建一个sqlazure数据库,如果不存在的话 2.在SQLdatabase中创建表(如果它们不存在) 3.最终从SQLDW读取数据并将其插入SQLdatabas ...
  • 注意:以下建议适用于帖子。 此行为将来可能会发生变化。 今天没有一种直接的方法可以做到这一点。 我添加了一个功能请求,用于通过TSQL发现服务目标的方法。 作为快捷方式,您可以运行以下命令: SELECT name, recovery_model, recovery_model_desc FROM sys.databases WHERE name = DB_NAME(); 如果recovery_model = 3(SIMPLE),则这是SQL数据仓库数据库。 如果r ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)