spring 线程池_Spring线程池服务

spring 线程池

线程池对于执行同步和异步过程非常重要。 本文介绍如何使用Spring开发和监视线程池服务。 创建线程池已通过两种替代方法进行了说明。

二手技术

JDK 1.6.0_21
春天3.0.5
Maven的3.0.2

步骤1:建立已完成的专案

创建一个Maven项目,如下所示。 (可以使用Maven或IDE插件创建)。

步骤2:图书馆

Spring依赖项已添加到Maven的pom.xml中。

<!-- Spring 3 dependencies -->
<dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version>
</dependency>

为了创建runnable-jar,可以使用以下插件。

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>1.3.1</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><transformers><transformerimplementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"><mainClass>com.otv.exe.Application</mainClass></transformer><transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/spring.handlers</resource></transformer><transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/spring.schemas</resource></transformer></transformers></configuration></execution></executions>
</plugin>

第3步:创建任务班

通过实现Runnable接口可以创建一个新的TestTask类。 此类显示要执行的任务。

package com.otv.task;import org.apache.log4j.Logger;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class TestTask implements Runnable {private static Logger log = Logger.getLogger(TestTask.class);String taskName;public TestTask() {}public TestTask(String taskName) {this.taskName = taskName;}public void run() {try {log.debug(this.taskName + " : is started.");Thread.sleep(10000);log.debug(this.taskName + " : is completed.");} catch (InterruptedException e) {log.error(this.taskName + " : is not completed!");e.printStackTrace();}}@Overridepublic String toString() {return (getTaskName());}public String getTaskName() {return taskName;}public void setTaskName(String taskName) {this.taskName = taskName;}
}

步骤4:建立TestRejectedExecutionHandler类别

通过实现RejectedExecutionHandler接口创建TestRejectedExecutionHandler类。 如果没有空闲线程并且队列溢出,则将拒绝任务。 此类处理被拒绝的任务。

package com.otv.handler;import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;import org.apache.log4j.Logger;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class TestRejectedExecutionHandler implements RejectedExecutionHandler {private static Logger log = Logger.getLogger(TestRejectedExecutionHandler.class);public void rejectedExecution(Runnable runnable, ThreadPoolExecutor executor) {log.debug(runnable.toString() + " : has been rejected");}
}

步骤5:创建ITestThreadPoolExecutorService接口

ITestThreadPoolExecutorService接口已创建。

package com.otv.srv;import java.util.concurrent.ThreadPoolExecutor;import com.otv.handler.TestRejectedExecutionHandler;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public interface ITestThreadPoolExecutorService {public ThreadPoolExecutor createNewThreadPool();public int getCorePoolSize();public void setCorePoolSize(int corePoolSize);public int getMaxPoolSize();public void setMaxPoolSize(int maximumPoolSize);public long getKeepAliveTime();public void setKeepAliveTime(long keepAliveTime);public int getQueueCapacity();public void setQueueCapacity(int queueCapacity);public TestRejectedExecutionHandler getTestRejectedExecutionHandler();public void setTestRejectedExecutionHandler(TestRejectedExecutionHandler testRejectedExecutionHandler);}

步骤6:建立TestThreadPoolExecutorService类别

通过实现ITestThreadPoolExecutorService接口来创建TestThreadPoolExecutorService类。 此类创建一个新的线程池。

package com.otv.srv;import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;import com.otv.handler.TestRejectedExecutionHandler;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class TestThreadPoolExecutorService implements ITestThreadPoolExecutorService {private int  corePoolSize;private int  maxPoolSize;private long keepAliveTime;private int  queueCapacity;TestRejectedExecutionHandler testRejectedExecutionHandler;public ThreadPoolExecutor createNewThreadPool() {ThreadPoolExecutor executor = new ThreadPoolExecutor(getCorePoolSize(),getMaxPoolSize(),getKeepAliveTime(),TimeUnit.SECONDS,new ArrayBlockingQueue(getQueueCapacity()),getTestRejectedExecutionHandler());return executor;}public int getCorePoolSize() {return corePoolSize;}public void setCorePoolSize(int corePoolSize) {this.corePoolSize = corePoolSize;}public int getMaxPoolSize() {return maxPoolSize;}public void setMaxPoolSize(int maxPoolSize) {this.maxPoolSize = maxPoolSize;}public long getKeepAliveTime() {return keepAliveTime;}public void setKeepAliveTime(long keepAliveTime) {this.keepAliveTime = keepAliveTime;}public int getQueueCapacity() {return queueCapacity;}public void setQueueCapacity(int queueCapacity) {this.queueCapacity = queueCapacity;}public TestRejectedExecutionHandler getTestRejectedExecutionHandler() {return testRejectedExecutionHandler;}public void setTestRejectedExecutionHandler(TestRejectedExecutionHandler testRejectedExecutionHandler) {this.testRejectedExecutionHandler = testRejectedExecutionHandler;}
}

步骤7:创建IThreadPoolMonitorService接口

IThreadPoolMonitorService接口已创建。

package com.otv.monitor.srv;import java.util.concurrent.ThreadPoolExecutor;public interface IThreadPoolMonitorService extends Runnable {public void monitorThreadPool();public ThreadPoolExecutor getExecutor();public void setExecutor(ThreadPoolExecutor executor);}

步骤8:创建ThreadPoolMonitorService类

ThreadPoolMonitorService类是通过实现IThreadPoolMonitorService接口创建的。 此类监视创建的线程池。

package com.otv.monitor.srv;import java.util.concurrent.ThreadPoolExecutor;
import org.apache.log4j.Logger;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class ThreadPoolMonitorService implements IThreadPoolMonitorService {private static Logger log = Logger.getLogger(ThreadPoolMonitorService.class);ThreadPoolExecutor executor;private long monitoringPeriod; public void run() {try {while (true){monitorThreadPool();Thread.sleep(monitoringPeriod*1000);}} catch (Exception e) {log.error(e.getMessage());}}public void monitorThreadPool() {StringBuffer strBuff = new StringBuffer();strBuff.append("CurrentPoolSize : ").append(executor.getPoolSize());strBuff.append(" - CorePoolSize : ").append(executor.getCorePoolSize());strBuff.append(" - MaximumPoolSize : ").append(executor.getMaximumPoolSize());strBuff.append(" - ActiveTaskCount : ").append(executor.getActiveCount());strBuff.append(" - CompletedTaskCount : ").append(executor.getCompletedTaskCount());strBuff.append(" - TotalTaskCount : ").append(executor.getTaskCount());strBuff.append(" - isTerminated : ").append(executor.isTerminated());log.debug(strBuff.toString());}public ThreadPoolExecutor getExecutor() {return executor;}public void setExecutor(ThreadPoolExecutor executor) {this.executor = executor;}   public long getMonitoringPeriod() {return monitoringPeriod;}public void setMonitoringPeriod(long monitoringPeriod) {this.monitoringPeriod = monitoringPeriod;}
}

第9步:创建入门课程

启动器类已创建。

package com.otv.start;import java.util.concurrent.ThreadPoolExecutor;import org.apache.log4j.Logger;import com.otv.handler.TestRejectedExecutionHandler;
import com.otv.monitor.srv.IThreadPoolMonitorService;
import com.otv.monitor.srv.ThreadPoolMonitorService;
import com.otv.srv.ITestThreadPoolExecutorService;
import com.otv.srv.TestThreadPoolExecutorService;
import com.otv.task.TestTask;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class Starter {private static Logger log = Logger.getLogger(TestRejectedExecutionHandler.class);IThreadPoolMonitorService threadPoolMonitorService;ITestThreadPoolExecutorService testThreadPoolExecutorService;public void start() {// A new thread pool is created...ThreadPoolExecutor executor = testThreadPoolExecutorService.createNewThreadPool();executor.allowCoreThreadTimeOut(true);// Created executor is set to ThreadPoolMonitorService...threadPoolMonitorService.setExecutor(executor);// ThreadPoolMonitorService is started...Thread monitor = new Thread(threadPoolMonitorService);monitor.start();// New tasks are executed...for(int i=1;i<10;i++) {executor.execute(new TestTask("Task"+i));}try {Thread.sleep(40000);} catch (Exception e)   {log.error(e.getMessage());}for(int i=10;i<19;i++) {executor.execute(new TestTask("Task"+i));}// executor is shutdown...executor.shutdown();}   public IThreadPoolMonitorService getThreadPoolMonitorService() {return threadPoolMonitorService;}public void setThreadPoolMonitorService(IThreadPoolMonitorService threadPoolMonitorService) {this.threadPoolMonitorService = threadPoolMonitorService;}public ITestThreadPoolExecutorService getTestThreadPoolExecutorService() {return testThreadPoolExecutorService;}public void setTestThreadPoolExecutorService(ITestThreadPoolExecutorService testThreadPoolExecutorService) {this.testThreadPoolExecutorService = testThreadPoolExecutorService;}
}

步骤10:创建应用程序类

应用程序类已创建。 此类运行应用程序。

package com.otv.start;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;/*** @author onlinetechvision.com* @since 17 Oct 2011* @version 1.0.0**/
public class Application {public static void main(String[] args) {ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");Starter starter = (Starter) context.getBean("Starter");starter.start();}}

步骤11:创建applicationContext.xml

applicationContext.xml已创建。

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><!-- Beans Declaration --><bean id="TestTask" class="com.otv.task.TestTask"></bean><bean id="ThreadPoolMonitorService" class="com.otv.monitor.srv.ThreadPoolMonitorService"><property name="monitoringPeriod"  value="5" /></bean><bean id="TestRejectedExecutionHandler" class="com.otv.handler.TestRejectedExecutionHandler"></bean><bean id="TestThreadPoolExecutorService" class="com.otv.srv.TestThreadPoolExecutorService"><property name="corePoolSize"  value="1" /><property name="maxPoolSize"   value="3" /><property name="keepAliveTime" value="10" /><property name="queueCapacity" value="3" /><property name="testRejectedExecutionHandler" ref="TestRejectedExecutionHandler" /></bean><bean id="Starter" class="com.otv.start.Starter"><property name="threadPoolMonitorService" ref="ThreadPoolMonitorService" /><property name="testThreadPoolExecutorService" ref="TestThreadPoolExecutorService" /></bean>
</beans>

步骤12:创建线程池的替代方法

Spring提供的ThreadPoolTask​​Executor类也可以用于创建线程池。

<bean id="threadPoolTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"><property name="corePoolSize"  value="1" /><property name="maxPoolSize"   value="3" /><property name="queueCapacity" value="3" />
</bean><bean id="testTaskExecutor" class="TestTaskExecutor"><constructor-arg ref="threadPoolTaskExecutor" />
</bean>

步骤13:建立专案

生成OTV_Spring_ThreadPool项目后,将创建OTV_Spring_ThreadPool-0.0.1-SNAPSHOT.jar

步骤14:运行项目

运行创建的OTV_Spring_ThreadPool-0.0.1-SNAPSHOT.jar文件后,将在下面显示输出日志:

18.10.2011 20:08:48 DEBUG (TestRejectedExecutionHandler.java:19) - Task7 : has been rejected
18.10.2011 20:08:48 DEBUG (TestRejectedExecutionHandler.java:19) - Task8 : has been rejected
18.10.2011 20:08:48 DEBUG (TestRejectedExecutionHandler.java:19) - Task9 : has been rejected
18.10.2011 20:08:48 DEBUG (TestTask.java:25) - Task1 : is started.
18.10.2011 20:08:48 DEBUG (TestTask.java:25) - Task6 : is started.
18.10.2011 20:08:48 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 2 - CompletedTaskCount : 0 - TotalTaskCount : 5 - isTerminated : false
18.10.2011 20:08:48 DEBUG (TestTask.java:25) - Task5 : is started.
18.10.2011 20:08:53 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 0 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:08:58 DEBUG (TestTask.java:27) - Task6 : is completed.
18.10.2011 20:08:58 DEBUG (TestTask.java:27) - Task1 : is completed.
18.10.2011 20:08:58 DEBUG (TestTask.java:25) - Task3 : is started.
18.10.2011 20:08:58 DEBUG (TestTask.java:25) - Task2 : is started.
18.10.2011 20:08:58 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 2 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:08:58 DEBUG (TestTask.java:27) - Task5 : is completed.
18.10.2011 20:08:58 DEBUG (TestTask.java:25) - Task4 : is started.
18.10.2011 20:09:03 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 3 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:09:08 DEBUG (TestTask.java:27) - Task2 : is completed.
18.10.2011 20:09:08 DEBUG (TestTask.java:27) - Task3 : is completed.
18.10.2011 20:09:08 DEBUG (TestTask.java:27) - Task4 : is completed.
18.10.2011 20:09:08 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 6 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:09:13 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 6 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:09:18 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 0 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 6 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:09:23 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 0 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 6 - TotalTaskCount : 6 - isTerminated : false
18.10.2011 20:09:28 DEBUG (TestTask.java:25) - Task10 : is started.
18.10.2011 20:09:28 DEBUG (TestRejectedExecutionHandler.java:19) - Task16 : has been rejected
18.10.2011 20:09:28 DEBUG (TestRejectedExecutionHandler.java:19) - Task17 : has been rejected
18.10.2011 20:09:28 DEBUG (TestRejectedExecutionHandler.java:19) - Task18 : has been rejected
18.10.2011 20:09:28 DEBUG (TestTask.java:25) - Task14 : is started.
18.10.2011 20:09:28 DEBUG (TestTask.java:25) - Task15 : is started.
18.10.2011 20:09:28 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 6 - TotalTaskCount : 12 - isTerminated : false
18.10.2011 20:09:33 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 6 - TotalTaskCount : 12 - isTerminated : false
18.10.2011 20:09:38 DEBUG (TestTask.java:27) - Task10 : is completed.
18.10.2011 20:09:38 DEBUG (TestTask.java:25) - Task11 : is started.
18.10.2011 20:09:38 DEBUG (TestTask.java:27) - Task14 : is completed.
18.10.2011 20:09:38 DEBUG (TestTask.java:27) - Task15 : is completed.
18.10.2011 20:09:38 DEBUG (TestTask.java:25) - Task12 : is started.
18.10.2011 20:09:38 DEBUG (TestTask.java:25) - Task13 : is started.
18.10.2011 20:09:38 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 9 - TotalTaskCount : 12 - isTerminated : false
18.10.2011 20:09:43 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 3 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 3 - CompletedTaskCount : 9 - TotalTaskCount : 12 - isTerminated : false
18.10.2011 20:09:48 DEBUG (TestTask.java:27) - Task11 : is completed.
18.10.2011 20:09:48 DEBUG (TestTask.java:27) - Task13 : is completed.
18.10.2011 20:09:48 DEBUG (TestTask.java:27) - Task12 : is completed.
18.10.2011 20:09:48 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 0 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 12 - TotalTaskCount : 12 - isTerminated : true
18.10.2011 20:09:53 DEBUG (ThreadPoolMonitorService.java:39) - CurrentPoolSize : 0 - CorePoolSize : 1 - MaximumPoolSize : 3 - ActiveTaskCount : 0 - CompletedTaskCount : 12 - TotalTaskCount : 12 - isTerminated : true

步骤15:下载

OTV_Spring_ThreadPool

参考: 如何使用我们JCG合作伙伴提供的 Spring开发和监视线程池服务   在线技术愿景博客的Eren Avsarogullari。


翻译自: https://www.javacodegeeks.com/2012/02/spring-thread-pool-services.html

spring 线程池

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/356625.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

arrayQueue

用数组实现队列&#xff1a; 定义头文件&#xff1a; 1 #include<stdio.h>2 #include<stdlib.h>3 #define MAX_SIZE 104 int queue[MAX_SIZE];5 int front-1;6 int rear-1;7 8 int IsFull(int queue[]); //判断队列是否已满 9 int IsEmpty(int queue[]); …

109. Convert Sorted List to Binary Search Tree

不定期更新leetcode解题java答案。 采用pick one的方式选择题目。 题意为将一个增序单链表转换成为二叉搜索树。 可以采用递归的方式依次确认该层应选择的单链表位置作为树的节点依次向下进行。每次选择做树该层的节点为链表的中间值。 代码如下&#xff1a; 1 /**2 * Definit…

带有骆驼,ActiveMQ,Elasticsearch的HL7关键用例

对于可以说HL7协议格式的系统&#xff0c; HL7 over MLLP是一种非常常见的传输机制。 JBoss Fuse是一个非常强大的微服务样式集成平台&#xff0c;在为关键医疗保健提供者构建灵活&#xff0c;有弹性&#xff0c;高可用性的集成方案方面拥有良好的记录。 此外&#xff0c;在JCA…

android 包裹内容,Android开发中Bundle用法 包裹数据

SDK里是这样描述&#xff1a;A mapping from String values to various Parcelable types。它帮助我将数据打包传入intent里面&#xff0c;为使用这些数据提供了便利。protected void onListItemClick (ListView l, View v, int position, long id){super.onListItemClick(l, v…

安卓高级6 SnackBar

引言 文&#xff0f;李牧羊&#xff08;简书作者&#xff09; 原文链接&#xff1a;http://www.jianshu.com/p/2654e6bda3b1 著作权归作者所有&#xff0c;转载请联系作者获得授权&#xff0c;并标注“简书作者”。 在之前我有提到这一篇Android Design Support Library系列文章…

html语言及语法结构,HTML语法结构.ppt

HTML语法结构HTML超文本标识语言 HTML超文本标识语言 HTML概念 HTML(Hyper Text Markup Language 超文本标识语言) 是一种用来制作超文本文档的简单标记语言。用HTML编写的超文本文档称为HTML文档。 HTML超文本标识语言 HTML文档的编写方法 1.手 工 直 接 编 写 记事本等&#…

利用Aspose.Word控件实现Word文档的操作

Aspose系列的控件&#xff0c;功能都挺好&#xff0c;之前一直在我的Winform开发框架中用Aspose.Cell来做报表输出&#xff0c;可以实现多样化的报表设计及输出&#xff0c;由于一般输出的内容比较正规化或者多数是表格居多&#xff0c;所以一般使用Aspose.Cell来实现我想要的各…

html编码自动识别,html实体编码遇上js代码

摘要&#xff1a; 在js中单、双引号引起来的是字符串&#xff0c;如果我们要在字符串中使用单、双引号&#xff0c;需要反斜杠进行转义。而如果字符串出现在html标签中&#xff0c;我们需要做转义处理。单双引号在js代码中在js中单、双引号引起来的是字符串&#xff0c;如果我们…

jpa动态扩展sql_扩展您的JPA POJO

jpa动态扩展sql可扩展性是许多体系结构的重要特征。 它衡量是否容易&#xff08;或困难&#xff09; 它是在不影响现有核心系统功能的情况下添加或更改功能。 让我们举一个简单的例子。 假设您的公司拥有一个核心产品来跟踪体育俱乐部中的所有用户。 在您的产品体系结构中&…

手机 html 折叠效果,HTML5仿苹果手机的面板合拢折叠效果

passbook仿苹果手机的面板合拢折叠效果-html5特效.pocket{width:300px;height:460px;padding: 10px;overflow: hidden;float: left;border: 1px solid #EDEDED;margin: 4px;border-radius: 8px;box-shadow:0 -5px 30px rgba(0,0,0,0.2) inset;}.passcard {float: left;width:30…

Activiti中具有单独数据库模式的多租户

我们过去听到的一项功能请求是以多租户方式运行Activiti引擎&#xff0c;使租户的数据与其他租户的数据隔离。 当然&#xff0c;在某些云/ SaaS环境中&#xff0c;这是必须的。 几个月前&#xff0c;波恩大学的学生拉斐尔吉伦&#xff08;Raphael Gielen&#xff09;与我接触&…

dfs手写栈模板

在竞赛中如果系统栈很小的话&#xff0c;过深的递归会让栈溢出&#xff0c;这个时候我们就要自己手写栈&#xff0c;将递归转化成手工栈。 方法其实也很简单。 基本思路上&#xff0c;我们就是用栈不断的pop,push。但是何时push&#xff0c;何时pop呢&#xff1f; 在《算法导论…

html5自动把某个层放在屏幕底部,告诉你一个将 footer 保持在底部的最好方法

当你在布局网页时&#xff0c;有可能会遇到类似下面的这种情况broken_layout.png导致这一问题的原因是页面内容太少&#xff0c;无法将内容区域撑开&#xff0c;从而在 footer 下面留下一大块空白。本文将介绍一种现代化的方法&#xff0c;&#xfffd;确保 footer 始终处于页面…

前后数据交互(ajax) -- 初始化页面表格

// 初始化员工信息列表 function loadpage ( pageNum ) {var keywords $("#keywords").val();$("#tbody").html("");if ( isNaN(pageNum) ) {pageNum 1;}$.$.ajax({type: GET,url: contextPath "/getaccountList/" pageNum "…

html的扇形代码导航,CSS3--利用transform和transition属性制作扇形导航

在前面&#xff0c;我们已经讲解了transform这个属性以及案例&#xff0c;那么本文会进一步结合transform和transition两个属性&#xff0c;并制作一个简单的案例进行说明。一、transition属性说明接下来简单分析一下transition这个属性的定义以及子属性。1)ansition-property …

UCI数据

http://archive.ics.uci.edu/ml/datasets.html?format&task&att&area&numAtt&numIns&type&sortinstDown&viewtable转载于:https://www.cnblogs.com/zangrunqiang/p/5999238.html

常见的误解:这会创建多少个对象?

总览 一个常见的问题是一段代码创建多少个对象或多少个字符串。 答案通常不是您的想法&#xff0c;也不是您真正需要知道的。 了解何时创建对象是很有用的&#xff0c;但是有很多其他因素通常要考虑的重要得多&#xff0c;这可能意味着应用程序总数不是您所想的。 字符串不是一…

cvs配电保护断路器_电工电器(三)-配电电器-断路器类-剩余电流保护断路器

本文文字836&#xff0c;阅读时间6分钟左右。此系列文章 从配电电器的大类等进行慢慢阐述&#xff0c;有不足的地方 欢迎大家相互探讨交流。配电电器&#xff0c;顾名思义就是进行电力分配的设备。电&#xff0c;从发电机出来之后&#xff0c;由总线输出&#xff0c;不可能直接…

html模块殃射,【Web前端问题】webpack打包后,module模块中的函数无法在html标签的事件中调用?...

折腾了好久&#xff0c;求大佬指点~~最近才开始接触webpack以及ES6的module&#xff0c;可能理解的有问题吧。。。希望大佬来指点一下我这个菜鸟。我的想法是在一个module中定义函数&#xff0c;在HTML的中用onclick事件调用这个函数。module模块代码&#xff1a;— base.js —…

Linux网络参数设置

1、ifconfig 查询、设定网络卡与ip 设置桥接网络 # vi /etc/sysconfig/network-script/ifcfg-br0DEVICEbr0 #设备名称BOOTPROTOstatic #设置静态地址IP6INITnoMTU1500 #设置MTU连接数 (可以设定不同的MTU数值)NM_CONTROLLEDnoONBOOTyesIPADDR…