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

柳州市网站建设_网站建设公司_轮播图_seo优化

网站建设公司怎么运营,广州商城网站制作网站,电子商务网站开发的课程介绍,西安网站运营招聘可用的工具是#xff1a;等待/通知 – 我们都试图摆脱这个古老的系统.信号量 – 一旦你的线程抓住它,你持有它直到释放,所以再次抓住它不会阻止.这意味着您无法在自己的线程中暂停.CyclicBarrier – 每次使用时都必须重新创建.ReadWriteLock – 我的最爱.您可以让任意多个线程…可用的工具是等待/通知 – 我们都试图摆脱这个古老的系统.信号量 – 一旦你的线程抓住它,你持有它直到释放,所以再次抓住它不会阻止.这意味着您无法在自己的线程中暂停.CyclicBarrier – 每次使用时都必须重新创建.ReadWriteLock – 我的最爱.您可以让任意多个线程暂停,并且只有当所有线程都调用了简历时才能恢复.如果你愿意,你甚至可以暂停一下.import java.util.concurrent.locks.ReadWriteLock;import java.util.concurrent.locks.ReentrantReadWriteLock;/*** PauseableThread is a Thread with pause/resume and cancel methods.** The meat of the process must implement step.** You can either extend this and implement step or use the factory.** Note that I cannot extend Thread because my resume will clash with Threads deprecated one.** Usage: Either write a Stepper and run it in a PausableThread or extend PausableThread and call blockIfPaused() at appropriate points.*/public abstract class PauseableThread implements Runnable {// The lock.// Well hold a read lock on it to pause the thread.// The thread will momentarily grab a write lock on it to pause.// This way you can have multiple pausers using normal locks.private final ReadWriteLock pause new ReentrantReadWriteLock();// Flag to cancel the wholeprocess.private volatile boolean cancelled false;// The exception that caused it to finish.private Exception thrown null;Override// The core run mechanism.public void run() {try {while (!cancelled) {// Block here if were paused.blockIfPaused();// Do my work.step();}} catch (Exception ex) {// Just fall out when exception is thrown.thrown ex;}}// Block if pause has been called without a matching resume.private void blockIfPaused() throws InterruptedException {try {// Grab a write lock. Will block if a read lock has been taken.pause.writeLock().lockInterruptibly();} finally {// Release the lock immediately to avoid blocking when pause is called.pause.writeLock().unlock();}}// Pause the work. NB: MUST be balanced by a resume.public void pause() {// We can wait for a lock here.pause.readLock().lock();}// Resume the work. NB: MUST be balanced by a pause.public void resume() {// Release the lock.pause.readLock().unlock();}// Stop.public void cancel() {// Stop everything.cancelled true;}// start - like a thread.public void start() {// Wrap it in a thread.new Thread(this).start();}// Get the exceptuion that was thrown to stop the thread or null if the thread was cancelled.public Exception getThrown() {return thrown;}// Create this method to do stuff.// Calls to this method will stop when pause is called.// Any thrown exception stops the whole process.public abstract void step() throws Exception;// Factory to wrap a Stepper in a PauseableThreadpublic static PauseableThread make(Stepper stepper) {StepperThread pauseableStepper new StepperThread(stepper);// Thats the thread they can pause/resume.return pauseableStepper;}// One of these must be used.public interface Stepper {// A Stepper has a step method.// Any exception thrown causes the enclosing thread to stop.public void step() throws Exception;}// Holder for a Stepper.private static class StepperThread extends PauseableThread {private final Stepper stepper;StepperThread(Stepper stepper) {this.stepper stepper;}Overridepublic void step() throws Exception {stepper.step();}}// My test counter.static int n 0;// Test/demo.public static void main(String[] args) throws InterruptedException {try {// Simple stepper that just increments n.Stepper s new Stepper() {Overridepublic void step() throws Exception {n 1;Thread.sleep(10);}};PauseableThread t PauseableThread.make(s);// Start it up.t.start();Thread.sleep(1000);t.pause();System.out.println(Paused: n);Thread.sleep(1000);System.out.println(Resuminng: n);t.resume();Thread.sleep(1000);t.cancel();} catch (Exception e) {}}}编辑修改代码以更常用.
http://www.ihoyoo.com/news/92688.html

相关文章:

  • 高效网站建设咨询重庆微信网站制作价格
  • 外贸网站开发公章在线印章制作生成免费
  • 上海网站开发薪资室内设计联盟邀请码怎么弄
  • 海会主机做的网站都能干什么的国开行网站毕业申请怎么做
  • 个人网站设计总结网站sem怎么做
  • 企业网站系统详细设计站长基地
  • 360浏览器打不开90设计网站深圳网站制作网站建设怎么制作网站深圳博纳
  • 做企业网站建设免费绘画素材网站
  • 网站不能粘贴怎么做只做一种产品的网站
  • 网站开发期末作品代码和数据库运行好大全淘宝上面建设网站安全么
  • 制作网页网站代码营口建网站
  • 网站哪家公司做的办公室设计说明万能模板
  • 有没有代做毕业设计的网站如何建网站开网店
  • 免费行情软件app网站大全下载免费入口建站公司还有前途吗
  • 移动版网站建设的必要性网站建设太金手指六六十八
  • 网站建设可用性的五个方面旅游网站建设公司哪家好
  • 给别人做网站需要增值电信东莞网页制作费用
  • 赛车pk10计划网站建设潍坊百度网站
  • 想做一个赌钱网站怎么做网站优化 套站
  • 网站建设ppt百度域名提交收录网址
  • 官方网站英语广西网站设计欣赏
  • 学做美食的视频网站wordpress 导入json
  • 网站编程用什么语言wordpress优化加速插件
  • 气象服务网站建设wordpress积分阅读
  • 中山那些网站公司做网站难度大吗
  • 东莞企业营销型网站网站建设责任书
  • 企业购网站建设wordpress the7数据库
  • 建设银行天津分行门户网站百度地图开发网站
  • 网页设计共享网站创作服务平台
  • 网站推广论坛wordpress数据库内容调用