如何偷窃局域网其它电脑文件

Before talking about Work Stealing, we need to talk about task management. We could use Tomcat as one example. Tomcat will use multiple threads to handle concurrent connections. The number of threads can go very high when there are many concurrent connections at the same time.

在谈论工作窃取之前,我们需要谈论任务管理。 我们可以使用Tomcat为例。 Tomcat将使用多个线程来处理并发连接。 当同时存在多个并发连接时,线程数可能会非常高。

However, a computer has a fixed number of cores. The number of threads that could be run at the same time is equal to the number of cores. All other threads have to be in waiting/ready states. The ready state threads will be scheduled to take over the CPU when the current running thread starts to do blocking IO. Scheduling in and out of threads is done by OS and it takes time. Too many threads will also consume more system resources, like the memory used for the thread data structure. Too many threads will also hurt cache locality.

但是,计算机具有固定数量的内核。 可以同时运行的线程数等于内核数。 所有其他线程必须处于等待/就绪状态。 当当前正在运行的线程开始阻塞IO时,就绪状态线程将被调度为接管CPU。 线程的进出调度是由OS完成的,这需要时间。 太多的线程也会消耗更多的系统资源,例如用于线程数据结构的内存。 线程过多也会损害缓存的局部性。

The ideal number of threads is the number of cores, and each thread is running on its own core without being scheduled out. However, this is the ideal case. Because when one thread is invoking a blocking IO API, the thread will be put into waiting state by OS. Another ready thread will be scheduled in to use the CPU. Currently, many DB drivers are being rewritten to support nonblocking API. These DB drivers include mongo, redis, cassandra, etc. But MySQL DB driver does not support nonblocking IO.

理想的线程数是核心数,每个线程都在自己的核心上运行,而不会被调度。 但是,这是理想的情况。 因为当一个线程正在调用阻塞的IO API时,该线程将被OS置于等待状态。 将安排另一个就绪线程来使用CPU。 当前,许多数据库驱动程序正在被重写以支持非阻塞API。 这些数据库驱动程序包括mongo,redis,cassandra等。但是MySQL数据库驱动程序不支持非阻塞IO。

If we could not control third party blocking API, but we could control our own code. When we are writing our own tasks, if there are no blocking IOs involved, we don’t have to block one thread on the output of another thread.

如果我们无法控制第三方阻止API,但可以控制自己的代码。 在编写自己的任务时,如果不涉及阻塞的IO,则不必在另一个线程的输出上阻塞一个线程。

JDK and third party projects are also doing a lot of work on how to smartly manage task dependencies, trying to introduce as less as threads as possible to squeeze the CPU usage for one thread. This includes ForkJoinPool, Reactor Project, Netty, Project Loom etc.

JDK和第三方项目还在如何巧妙地管理任务依赖项方面进行了大量工作,试图引入尽可能少的线程以压缩一个线程的CPU使用率。 这包括ForkJoinPool ,Reactor Project,Netty,Project Loom等。

Since JDK 7, ForkJoinPool is introduced. The important thing about ForkJoinPool is that it’s created with the following ruling points.

从JDK 7开始,引入了ForkJoinPoolForkJoinPool的重要之处在于它是根据以下规则创建的。

  • Each thread has its own task queue. Each task queue is a cicular array.每个线程都有自己的任务队列。 每个任务队列都是一个针状阵列。
  • Each thread uses push and pop to add or remove tasks to its own queue.每个线程都使用推和弹出将任务添加或删除到自己的队列中。
  • ForkJoinPool uses the work-stealing algorithm to balance the workload on different threads. The pool maintains a global work queue that stores externally submitted tasks. Each worker thread will pop tasks from its own task queue. If there are no tasks in its own queue, it will try to randomly steal tasks from the shared work queues or other workers. If it fails to find tasks from both shared queues or other threads, it will go to sleep.

    ForkJoinPool的用途 工作窃取算法以平衡不同线程上的工作负载。 该池维护一个全局工作队列,该队列存储外部提交的任务。 每个工作线程将从其自己的任务队列中弹出任务。 如果自己的队列中没有任务,它将尝试从共享工作队列或其他工作线程中随机窃取任务。 如果它无法从共享队列或其他线程中查找任务,它将进入睡眠状态。

push: used by worker thread to push task to the top of its own work queuepop: used by worker thread to pop task from the top of its own workpoll: used by other thread to steal task from the bottom of the work queue of a different thread

Since this work-stealing algorithm is so general, it could be used in all other languages to manage task scheduling. For example, in Kotlin and Python, there are coroutines. A coroutine can be considered as user-space light thread. It does not involve scheduling of OS. It’s completely user-space task scheduling. The benefits of it are that it could use very few threads to manage the tasks. Project Loom is also introducing Fiber in Java. Fiber is similar to Coroutine.

由于此工作窃取算法是如此通用,因此可以在所有其他语言中使用它来管理任务调度。 例如,在KotlinPython中 ,有协程。 协程可以视为用户空间光线程。 它不涉及操作系统调度。 这完全是用户空间的任务调度。 它的好处是它可以使用很少的线程来管理任务。 Project Loom也正在Java中引入Fiber。 纤维类似于协程。

The general trend for user application development is tending to use lighter threads to manage user tasks. It achieves better performance with a lower number of threads, non-blocking IO, and user-space task management.

用户应用程序开发的总体趋势是倾向于使用较轻的线程来管理用户任务。 它以较少的线程数,无阻塞的IO和用户空间任务管理实现了更好的性能。

CompletableFuture

未来发展

CompletableFuture internally uses ForkJoinPool to manage the scheduling of the tasks. The following is one simple example.

CompletableFuture在内部使用ForkJoinPool来管理任务的调度。 以下是一个简单的示例。

CompletableFuture.supplyAsync(() -> {    try {        Thread.sleep(30000);    } catch (InterruptedException e) {        e.printStackTrace();    }    System.out.println("current thread is "+Thread.currentThread().getId());    return Thread.currentThread().getId();}).thenCombineAsync(CompletableFuture.supplyAsync(() -> {    try {        Thread.sleep(70000);    } catch (InterruptedException e) {        e.printStackTrace();    }    System.out.println("current thread is "+Thread.currentThread().getId());    return Thread.currentThread().getId();}), (l, r) -> l + r)        .thenAcceptAsync(x ->        {            System.out.println("current thread is "+Thread.currentThread().getId());        }).thenRunAsync(() -> {            System.out.println("current thread is "+Thread.currentThread().getId());        });

supplyAsync by its name is saying its forking one Async Task. This task will be submitted to ForkJoinPool. ForkJoinPool will use one worker thread to run it.

supplyAsync的名称是说它分叉了一个异步任务。 该任务将被提交到ForkJoinPool。 ForkJoinPool将使用一个工作线程来运行它。

combineAsync says that it should combine the result of the previous two submitted tasks. Since comebineAsync depends on the previous task results, so CompletableFuture will not start a new thread for this task. It uses the existing thread to run the task when the dependent tasks are finished.

CombineAsync表示应合并前两个已提交任务的结果。 由于comebineAsync取决于先前的任务结果,因此CompletableFuture不会为此任务启动新线程。 相关任务完成后,它将使用现有线程来运行任务。

runAsync is just submitting another independent task to ForkJoinPool.

runAsync只是向ForkJoinPool提交另一个独立的任务。

There are many APIs in CompletableFuture. The way to construct CompletableFuture tasks is very similar to Promise in frontend. When many callbacks are chained together, it could make the code not so readable. Some third-party libraries introduced language constructs async and await in Java similar to Javascript promise.

CompletableFuture中有许多API 构造CompletableFuture任务的方式与前端的Promise非常相似。 当许多回调链接在一起时,可能会使代码不那么可读。 一些第三方库介绍语言结构异步和等待在Java中类似的Javascript承诺。

Work-Stealing algorithm is also used in Reactor Project. And it might also be in many other lower-level task scheduling frameworks, libraries, kernel task management, etc.

工作 算法也用于Reactor项目中。 它也可能存在于许多其他较低级别的任务调度框架,库,内核任务管理等中。

If you want to know the details of Work-Stealing algorithm, you could read the paper and the source code of the ForkJoinPool.

如果您想了解Work-Stealing算法的详细信息,可以阅读ForkJoinPool的论文和源代码

https://hg.openjdk.java.net/jdk/jdk11/file/1ddf9a99e4ad/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java#l1348

https://hg.openjdk.java.net/jdk/jdk11/file/1ddf9a99e4ad/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java#l1348

https://www.dre.vanderbilt.edu/~schmidt/PDF/work-stealing-dequeue.pdf

https://www.dre.vanderbilt.edu/~schmidt/PDF/work-stealing-dequeue.pdf

Please leave a comment if you find anything wrong.

如果发现任何错误,请发表评论。

翻译自: https://medium.com/swlh/work-stealing-distilled-d2ed86d3065d

如何偷窃局域网其它电脑文件


http://www.taodudu.cc/news/show-5872529.html

相关文章:

  • 自动驾驶少了“技术偷窃”,还能玩得转吗?
  • 【每日一练】你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。
  • 偷窃—ACM
  • 制作简易的节日贺卡
  • Lark XR 平行云-云渲染方案
  • 什么是云渲染?云渲染速度快吗?
  • 9个应急word简历模板
  • 应届生标准求职简历表-Word简历可编辑下载
  • 找工作标准简历表-Word简历可编辑下载
  • 体育老师简历表-Word简历可编辑下载
  • Word简历中如何插入头像?
  • 会计专业为什么要学python-御丽诗妃:为什么我建议你一定要学Python?
  • python可以学会编程语言吗_为什么我建议你一定要学Python?
  • 小班计算机游戏教案,幼儿园小班游戏教案(精选5篇)
  • 用心起一个名字
  • 网络安全漏洞平台
  • 搭建本地 8.8 W 乌云漏洞库
  • php新手漏洞挖掘,php漏洞挖掘思路
  • 离线乌云漏洞详情vs知识库
  • 讨论一下,乌云漏洞库的学习方法
  • 360搜索网银防骗方法
  • 微软Process Monitor证实QQ“窥私门”事件
  • 详尽分析世纪之战:360VS腾讯是两个阶层的抗争 下
  • 3Q诉讼案开庭 腾讯称360诉讼书矛盾百出
  • 360声明 腾讯要挟用户卸载360 360将保证和QQ同时正常使用
  • 12306铁路订票系统的一个小bug
  • 语音计算机管家,小智超级音箱 你的智能语音管家
  • bl小说里面有个机器人管家_冰箱教你做菜 机器人当管家(图)
  • 团队项目:我要当管家
  • 乐动力推手表管家:Android Wear的中国化之路

如何偷窃局域网其它电脑文件_偷窃工作相关推荐

  1. 如何偷窃局域网其它电脑文件_糟糕的艺术家抄袭,伟大的艺术家偷窃,或者如何成为一名伟大的设计师...

    如何偷窃局域网其它电脑文件 by Teo Yu Siang 张玉祥 糟糕的艺术家抄袭,伟大的艺术家偷窃,或者如何成为一名伟大的设计师 (Bad artists copy, great artists ...

  2. 手机利用python访问电脑文件_黑客教程,一行python命令让手机读取电脑文件!

    本文讲解python的一个内置文件传输下载器,可以用来在局域网内进行文件传输,当然可能有人会问,我用微信QQ也能传,为什么还要用python来传输下载?在此,其实我个人感觉的是,这种操作更简单,省了时 ...

  3. 手机访问电脑文件_手机直接访问电脑文件,不用数据线,方便快速

    手机和电脑之间文件的交互办法有很多种,最简单的就是用数据线来进行文件的传输,或者用其它软件来实现文件面对面的交流.不过这些方法都有一些使用上的限制,不太方便.关注公众号 三角架创业支撑 获取更多资讯 ...

  4. 计算机桌面照片如何干净删除,怎么删除电脑文件_电脑文件如何删除干净-win7之家...

    删除电脑文件很简单的,平时我们右键单击后机有个删除选项,在点击进行确认即可删除,但删除文件时,都会先跑去回收站里,要在回收站里在进行删除才能彻底的删除,那么电脑文件如何删除干净呢,下面小编给大家分享删 ...

  5. python局域网控制电脑关机_局域网内计算机远程开机、控制和关机

    学校里有了卫星接收计算机,在获取大量教学资源的同时麻烦又来了,每天都要去开机启动程序接收,接收完了还要关机:接收的资源共享给了计算机教室,可要用这些资源时,也还是要打开卫星接收机.像有些学校几室弄得比 ...

  6. python局域网控制电脑关机_黑客操作:用python远程开机and关机

    前言 用python关机相信大家肯定听过或者实践过,那么用 Python 开机呢?这是一个神奇的方 法,教你如何用 Python 来开机. 本文目标远程开机原理 Python 远程开机代码实现 Pyt ...

  7. 手机访问电脑文件_你还在苦恼电脑和手机文件如何快速传输吗?

    对于很多商务人士来说,如何方便地在手机或PAD等移动设备上查看电脑上的文件,很多时候都显得那么重要. 目前,一般的解决方案有如下几种: 1.各类网盘:现在网盘的种类有很多,用得最多的,恐怕就是某度云了 ...

  8. 手机访问电脑文件_彻底解决手机-电脑互传大文件的难题 电脑-手机快捷互联互通...

    我们现在大多时候,手机和电脑传输数据都有用微信文件传输助手,或者QQ类型的功能.但是用这两个工具有2个问题,都是大于100M就不能传输了,而且传输图片的时候会进行压缩,即使你勾选了上传原图.所以我们需 ...

  9. 局域网传输文件_【电脑篇】巧借局域网,告别第三方工具便捷实现电脑间的文件传输...

    前言:笔记本和台式机现在已经成为了大多数人的标配,两台电脑相互配合,工作娱乐两不误.但是有时候,需要在两台电脑之间传输文件,我们往往更多的是借助qq传输或借助U盘或移动硬盘等第三方工具.这样其实很不方 ...

最新文章

  1. golang float string int 相互转换 保留小数位
  2. C++之shared_ptr总结
  3. 修改boot.ini
  4. autowired 与 resources 注解的区别
  5. Leetcode 133. 克隆图 解题思路及C++实现
  6. 单片机c语言 openssl,Linux下C语言使用openssl库进行加密
  7. java编程能做什么_学习Java编程能做什么工作?
  8. [转]C++中的三种继承public,protected,private
  9. mac mysql5.7.9 dmg_Mac 安装 mysql5.7
  10. Matplotlib中的“ plt”和“ ax”到底是什么?
  11. Github Action 快速构建 Electron 应用
  12. 回溯算法之幸运的袋子
  13. 优麒麟这样的linux版本,百度网盘 Linux 版发布,搭配优麒麟运行更完美!
  14. mysql 安装绑定my.ini
  15. 轮播 一张中间 两张在旁边_篮球不是单机游戏,在我旁边的还有我的队友!
  16. 信息论的基本概念(自信息,条件熵,联合熵,互信息,条件互信息)
  17. 【物联网】12.物联网服务器发送方式(HTTP,WebSocket ,MQTT )
  18. 【Apollo】【driver】【gnss】适配新的gps设备的方式与经验总结
  19. java的测试岗位_JAVA测试岗位职责
  20. java发送http请求 utf8_Java 发送http请求(get、post)的示例

热门文章

  1. 【历史上的今天】2 月 23 日:Enigma 密码机申请专利;戴尔电脑创始人出生;Mellanox 收购 EZchip
  2. Java SE 7 新特性
  3. 实时数仓 | 京东计算架构演进之路
  4. 头部3D建模新应用:护目镜类产品定制,省时高效好选择
  5. 身份证到期换新证流程
  6. 视频监控存储系统的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  7. windbg+virtualbox+win10双机调试
  8. 倾城之恋_拔剑-浆糊的传说_新浪博客
  9. zabbix5.0监控mysql服务
  10. 改变世界——牛逼的中国“80后”们