<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 18, 文章 - 0, 評論 - 8, 引用 - 0
    數(shù)據(jù)加載中……

    2017年7月10日

    CyclicBarrier 簡單舉例

    一句話解釋:預(yù)備~~~開始

     1 import java.util.concurrent.BrokenBarrierException;
     2 import java.util.concurrent.CyclicBarrier;
     3 
     4 import org.slf4j.Logger;
     5 import org.slf4j.LoggerFactory;
     6 
     7 public class CyclicBarrierLearn {
     8     
     9     private Logger log = LoggerFactory.getLogger(CyclicBarrierLearn.class);
    10     
    11     private class Work extends Thread {
    12         
    13         private String name;
    14         private CyclicBarrier cyclicBarrier;
    15         
    16         public Work(String name, CyclicBarrier cyclicBarrier) {
    17             this.name = name;
    18             this.cyclicBarrier = cyclicBarrier;
    19         }
    20         
    21         @Override
    22         public void run() {
    23             try {
    24                 log.debug("thread name: " + name + " waiting work");
    25                 cyclicBarrier.await();
    26                 log.debug("thread name: " + name + " working");
    27             } catch (InterruptedException e) {
    28                 e.printStackTrace();
    29             } catch (BrokenBarrierException e) {
    30                 e.printStackTrace();
    31             }
    32             
    33         }
    34     }
    35     
    36     public void cyclicBarrier() {
    37         CyclicBarrier cyclicBarrier = new CyclicBarrier(50, new Runnable() {
    38             
    39             @Override
    40             public void run() {
    41                 log.debug("let's begin work");
    42             }
    43         });
    44         
    45         for (int i = 0; i < cyclicBarrier.getParties(); i++) {
    46             Work work = new Work(String.valueOf(i), cyclicBarrier);
    47             work.start();
    48         }
    49         
    50     }
    51 
    52     public static void main(String[] args) {
    53         CyclicBarrierLearn cyclicBarrierLearn = new CyclicBarrierLearn();
    54         cyclicBarrierLearn.cyclicBarrier();
    55 
    56     }
    57 
    58 }
    59 

    posted @ 2017-07-13 11:39 丑男 閱讀(183) | 評論 (0)編輯 收藏

    CountDownLatch 簡單舉例

    一句話解釋:主線程阻塞,其他線程完成后,主線程被喚醒后繼續(xù)執(zhí)行

     1 import java.util.Random;
     2 import java.util.concurrent.CountDownLatch;
     3 
     4 import org.slf4j.Logger;
     5 import org.slf4j.LoggerFactory;
     6 
     7 public class CountDownLatchLearn {
     8     
     9     private Logger log = LoggerFactory.getLogger(CountDownLatchLearn.class);
    10     private CountDownLatch countDownLatch;
    11     
    12     public CountDownLatchLearn() {
    13         countDownLatch = new CountDownLatch(50);
    14     }
    15     
    16     public void countDown() {
    17         Long count = countDownLatch.getCount();
    18         log.debug("countDownLatch count is:" + count.toString());
    19         
    20         for (int i = 0; i < count; i++) {
    21             Work work = new Work(String.valueOf(i), countDownLatch);
    22             work.start();
    23         }
    24         try {
    25             countDownLatch.await();
    26         } catch (InterruptedException e) {
    27             e.printStackTrace();
    28         }
    29         log.debug("work finish!!!");
    30     }
    31     
    32     private class Work extends Thread {
    33         
    34         private String name;
    35         private CountDownLatch countDownLatch;
    36         
    37         public Work(String name, CountDownLatch countDownLatch) {
    38             this.name = name;
    39             this.countDownLatch = countDownLatch;
    40         }
    41         
    42         @Override
    43         public void run() {
    44             Random r = new Random();
    45             int sleep = r.nextInt(2000);
    46             try {
    47                 log.debug("thread sleep: "+ sleep);
    48                 Thread.sleep(sleep);
    49             } catch (InterruptedException e) {
    50                 e.printStackTrace();
    51             }
    52             log.debug("thread: " + name + ": do work");
    53             countDownLatch.countDown();
    54         }
    55     }
    56 
    57     public static void main(String[] args) {
    58         System.out.println("main start!!!");
    59         
    60         CountDownLatchLearn countDownLatchLearn = new CountDownLatchLearn();
    61         countDownLatchLearn.countDown();
    62         
    63         System.out.println("main end!!!");
    64     }
    65 
    66 }

    posted @ 2017-07-13 11:18 丑男 閱讀(318) | 評論 (0)編輯 收藏

    mysql 5.7 for windows安裝過程

    環(huán)境說明:

    OSwindows 7 64bit Databasemysql-5.7.18-winx64 Noinstall版本

     

    1. 解壓Mysql安裝目錄

    2. 編寫my.ini配置文件

    3. mysqld --defaults-file=../my.ini --initialize

    4. ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

    5. mysql –u root –p

    6. 密碼在logs/*.err日志中

     
    my.ini文件內(nèi)容

     1 # my.ini文件內(nèi)容
     2 # For advice on how to change settings please see
     3 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
     4 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
     5 # *** default location during install, and will be replaced if you
     6 # *** upgrade to a newer version of MySQL.
     7 
     8 [mysqld]
     9 
    10 # Remove leading # and set to the amount of RAM for the most important data
    11 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    12 # innodb_buffer_pool_size = 128M
    13 
    14 # Remove leading # to turn on a very important data integrity option: logging
    15 # changes to the binary log between backups.
    16 # log_bin
    17 
    18 # These are commonly set, remove the # and set as required.
    19 basedir=D:\\mysql-5.7.18-winx64
    20 datadir=D:\\mysql-5.7.18-winx64\\data
    21 # port = ..
    22 # server_id = ..
    23 
    24 
    25 # Remove leading # to set options mainly useful for reporting servers.
    26 # The server defaults are faster for transactions and fast SELECTs.
    27 # Adjust sizes as needed, experiment to find the optimal values.
    28 # join_buffer_size = 128M
    29 # sort_buffer_size = 2M
    30 # read_rnd_buffer_size = 2M 
    31 
    32 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    33 
    34 long_query_time=0.1
    35 slow_query_log=on
    36 slow_query_log_file=D:\\mysql-5.7.18-winx64\\logs\\mysqlslow.log
    37 

    posted @ 2017-07-10 00:53 丑男 閱讀(220) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲黄色一级毛片| 久久久久无码精品亚洲日韩 | 波多野结衣中文字幕免费视频| 中文亚洲AV片在线观看不卡| 羞羞视频免费网站日本| 亚洲国产日韩在线观频| 一级做a爰片久久毛片免费陪 | 国产免费牲交视频| 亚洲国产精品成人午夜在线观看 | 久久久久久国产a免费观看不卡| 亚洲国产成人久久综合碰| 国产亚洲综合一区二区三区| 国产免费卡一卡三卡乱码| 一级中文字幕免费乱码专区| 亚洲精品国产精品乱码不99| 国产成人久久AV免费| 亚洲日本视频在线观看| 好爽又高潮了毛片免费下载| 美女露隐私全部免费直播| 中文字幕精品无码亚洲字| 久久大香香蕉国产免费网站 | 1000部禁片黄的免费看| 亚洲国产精品无码久久久| 免费毛片在线看片免费丝瓜视频 | 亚洲一区二区三区成人网站| 国产青草视频免费观看97| 一区二区视频免费观看| 亚洲第一精品在线视频| 精品熟女少妇AV免费观看| 美景之屋4在线未删减免费| 久久被窝电影亚洲爽爽爽| 精品久久久久久久久免费影院| 亚洲国产精品久久久久秋霞小| 亚洲中文字幕无码一区二区三区| 三年片在线观看免费观看大全动漫| 亚洲日韩在线视频| 五月婷婷亚洲综合| 97在线视频免费公开观看| 在线观看亚洲免费| 亚洲AV乱码久久精品蜜桃| 在线精品免费视频|