From d1e380d5bc8d6cda7dc26778dd638b3367483ae7 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期五, 11 四月 2025 17:27:30 +0800 Subject: [PATCH] 小程序6种开关阀操作失败时重发一次 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/Test.java | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 157 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/Test.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/Test.java new file mode 100644 index 0000000..37eec13 --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/Test.java @@ -0,0 +1,157 @@ +package com.dy.common.threadPool; + + +public class Test { + +// +// public static void main(String args[])throws Exception { +//// Test t = new Test(); +//// t.testShort1(); +//// t.testShort2(); +//// t.testLong(); +// } + + /** + * 娴嬭瘯澧炲姞绾跨▼绾跨▼ + * @throws Exception + * + */ + @SuppressWarnings("unused") + private void testShort1() throws Exception { + TreadPoolFactory.initThreadPoolShort("娴嬭瘯绾跨▼缁�", 2, 1, 10, 20); + ThreadPool.Pool pool = TreadPoolFactory.getThreadPoolShort() ; + try { + int n = 1 ; + Thread.sleep(1000); + while (n < 4) { + System.out.println("鍔犲叆鐭伐浣滀换鍔�(" + n + ")"); + pool.putJob(new ThreadPool.Job() { + public void execute() { + System.out.println("!!!!!寮�濮嬬煭宸ヤ綔" + this.hashCode()); + try { + Thread.sleep(2000); + } catch (Exception e) { + ; + } + System.out.println("!!!!!缁撴潫鐭伐浣�" + this.hashCode()); + } + @Override + public void destroy(){ + } + @Override + public boolean isDestroy(){ + return false ; + } + }); + n++ ; + Thread.sleep(100); + } + } catch (Exception e) { + + } + } + /** + * 娴嬭瘯澧炲姞绾跨▼绾跨▼ + * @throws Exception + * + */ + @SuppressWarnings("unused") + private void testShort2() throws Exception { + TreadPoolFactory.initThreadPoolShort("娴嬭瘯鐭伐浣滅嚎绋嬬粍", 2, 1, 5, 6); + ThreadPool.Pool pool = TreadPoolFactory.getThreadPoolShort() ; + try { + int n = 1 ; + Thread.sleep(1000); + while (n < 2) { + System.out.println("鍔犲叆鐭伐浣滀换鍔�(" + n + ")"); + pool.putJob(new ThreadPool.Job() { + @Override + public void execute() { + Long times = 0L ; + System.out.println("!!!!!寮�濮嬬煭宸ヤ綔" + this.hashCode()); + while(true){ + if(this.isDestroy == null || !this.isDestroy.booleanValue()){ + times++ ; + System.out.println("!!!!!鎵ц鐭伐浣�" + this.hashCode() + " 娆℃暟锛�" + times); + try { + Thread.sleep(2000); + } catch (Exception e) { + ; + } +// System.out.println("!!!!!缁撴潫闀垮伐浣�" + this.hashCode()); + } + } + } + @Override + public void destroy(){ + this.isDestroy = true ; + } + @Override + public boolean isDestroy(){ + if(this.isDestroy == null){ + return false ; + } + return this.isDestroy.booleanValue() ; + } + private Boolean isDestroy; + }); + n++ ; + Thread.sleep(100); + } + } catch (Exception e) { + + } + }/** + * 娴嬭瘯澧炲姞绾跨▼绾跨▼ + * @throws Exception + * + */ + @SuppressWarnings("unused") + private void testLong() throws Exception { + TreadPoolFactory.initThreadPoolLong("娴嬭瘯闀垮伐浣滅嚎绋嬬粍", -1, 1, 5, -1); + ThreadPool.Pool pool = TreadPoolFactory.getThreadPoolLong() ; + try { + int n = 1 ; + Thread.sleep(1000); + while (n < 2) { + System.out.println("鍔犲叆闀垮伐浣滀换鍔�(" + n + ")"); + pool.putJob(new ThreadPool.Job() { + @Override + public void execute() { + Long times = 0L ; + System.out.println("!!!!!寮�濮嬮暱宸ヤ綔" + this.hashCode()); + while(true){ + if(this.isDestroy == null || !this.isDestroy.booleanValue()){ + times++ ; + System.out.println("!!!!!鎵ц闀垮伐浣�" + this.hashCode() + " 娆℃暟锛�" + times); + try { + Thread.sleep(2000); + } catch (Exception e) { + ; + } +// System.out.println("!!!!!缁撴潫闀垮伐浣�" + this.hashCode()); + } + } + } + @Override + public void destroy(){ + this.isDestroy = true ; + } + @Override + public boolean isDestroy(){ + if(this.isDestroy == null){ + return false ; + } + return this.isDestroy.booleanValue() ; + } + private Boolean isDestroy; + }); + n++ ; + Thread.sleep(100); + } + } catch (Exception e) { + + } + } + +} -- Gitblit v1.8.0