当前位置: 首页 > news >正文

企业网站运维建站快车管理

企业网站运维,建站快车管理,wordpress 后台破解,做vip视频网站赚钱吗2024年10月14日14:17:07—0.6.0 java-实现一个简单的httpserver-0.6.0 背景功能具体代码打印 背景 通常写了一些接口#xff0c;需要通过临时的http访问#xff0c;又不需要spring这么厚重的框架 功能 设置并发监控并发两个get请求一个是根路径#xff0c;一个是other增加… 2024年10月14日14:17:07—0.6.0 java-实现一个简单的httpserver-0.6.0 背景功能具体代码打印 背景 通常写了一些接口需要通过临时的http访问又不需要spring这么厚重的框架 功能 设置并发监控并发两个get请求一个是根路径一个是other增加了一个post请求的方法other1 具体代码 import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer;import java.io.IOException; import java.io.OutputStream; import java.net.InetSocketAddress; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors;public class server {private static AtomicInteger concurrentConnections new AtomicInteger(0);public static void main(String[] args) throws IOException {HttpServer server HttpServer.create(new InetSocketAddress(localhost, 8222), 0);// 处理根路径get请求server.createContext(/, new RootHandler());// 处理 /other 路径get请求server.createContext(/other, new OtherHandler());// 处理 /other1 路径post请求server.createContext(/other1, new Other1Handler());// 设置并发连接数server.setExecutor(java.util.concurrent.Executors.newFixedThreadPool(10));server.start();System.out.println(Server started on port 8000.);// 定期打印当前并发连接数new Thread(() - {while (true) {try {Thread.sleep(5000);System.out.println(Current concurrent connections: concurrentConnections.get());} catch (InterruptedException e) {Thread.currentThread().interrupt();}}}).start();}static class RootHandler implements HttpHandler {Overridepublic void handle(HttpExchange exchange) throws IOException {concurrentConnections.incrementAndGet();if (GET.equals(exchange.getRequestMethod())) {String response Hello from root path!;exchange.sendResponseHeaders(200, response.length());OutputStream os exchange.getResponseBody();os.write(response.getBytes());os.close();// 监控连接释放事件System.out.println(root Connection released);}concurrentConnections.decrementAndGet();}}static class OtherHandler implements HttpHandler {Overridepublic void handle(HttpExchange exchange) throws IOException {concurrentConnections.incrementAndGet();if (GET.equals(exchange.getRequestMethod())) {String response This is a response for /other path.;exchange.sendResponseHeaders(200, response.length());OutputStream os exchange.getResponseBody();os.write(response.getBytes());os.close();}// 监控连接释放事件System.out.println(/other Connection released);concurrentConnections.decrementAndGet();}}static class Other1Handler implements HttpHandler {Overridepublic void handle(HttpExchange exchange) throws IOException {concurrentConnections.incrementAndGet();if (POST.equals(exchange.getRequestMethod())) {String response This is a response for /other1 post path.;exchange.sendResponseHeaders(200, response.length());OutputStream os exchange.getResponseBody();os.write(response.getBytes());os.close();}// 监控连接释放事件System.out.println(/other Connection released);concurrentConnections.decrementAndGet();}} } 打印 root Connection released Current concurrent connections: 0 /other Connection released root Connection released /other Connection released /other Connection released /other Connection released /other Connection released /other Connection released Current concurrent connections: 0 /other Connection released /other Connection released /other Connection released root Connection released Current concurrent connections: 0 Current concurrent connections: 0
http://www.hkea.cn/news/14465891/

相关文章:

  • 前端网站推荐美工培训班要多少学费
  • 旅游网站制作模板菏泽建设企业网站
  • 网站服务器租用合同wordpress页面定制
  • 食品经营许可网站增项怎么做网站描述作用
  • 本地网站有什么可以做前台登录 wordpress
  • 自己建网站的流程做俄罗斯网站
  • 网上做公益的网站有一个姑娘莱芜的莱芜的
  • 阿里云从哪里建设网站前端静态页面接单
  • 恐怖小说网站怎么做自应式网站
  • 泉州专业网站建设哪家好怎么导入模板到wordpress
  • 做淘客要有好的网站wordpress轻量化主题
  • 官方网站建设专家磐石网络宿舍网络规划与设计
  • 江苏建站管理系统开发社交公众号开发公司
  • 建设网站河北建设网禹州市城乡建设局网站
  • 广州企业网站建设哪家好cms系统都有哪些
  • 镇江外贸型网站建设开源crm客户管理系统
  • 视频门户网站建设方案北京运营推广网站建设
  • 亚马逊官方网站的建设oa系统开发教程
  • 加强网站和公众号建设商务网站如何推广
  • 网站备案时间查询网站做好了怎么和域名
  • 潍坊知名网站建设服务商做网站开发学什么
  • 成品网站app开发中小型电子商务网站
  • 网站维护一次多少钱官网建设
  • 做电影网站为什么要数据库现在都用什么做网站
  • 四川网站seo企业信息管理系统有哪些功能
  • 旅游做攻略网站莲湖微网站建设
  • 网站制作公司dedecms怎么使用wordpress里的主题
  • 网站开发自学网东莞一站式网站建设
  • 网站建设客户开发方法学习做网站
  • 北京城乡和住房建设部网站制作网站模板