zoukankan      html  css  js  c++  java
  • [20160730]while 条件的死循环和正常循环对比

    正常循环

     1 import java.io.*;
     2 import java.util.*;
     3 
     4 public class MyPrintStreamTest3{
     5   public static void main(String[] args) {
     6     BufferedReader br = new BufferedReader(  new InputStreamReader(System.in) );
     7     String s = null;
     8 
     9   try
    10   {
    11     PrintWriter log = new PrintWriter( new FileWriter("D://javalearning//MYIO//log4j.txt",true) );
    12     while((s = br.readLine())!=null){
    13       if (s.equalsIgnoreCase("exit")) break;
    14        System.out.println(s.toUpperCase());
    15        log.println("--------");
    16        log.println(s.toUpperCase());
    17        log.flush();
    18     }
    19     log.println("=="+new Date()+"==");
    20     log.flush();
    21     log.close();
    22 
    23   }
    24   catch (IOException e)
    25   {
    26      e.printStackTrace();
    27   }
    28 }
    29 }

    死循环

     1 import java.io.*;
     2 import java.util.*;
     3 
     4 public class MyPrintStreamTest3{
     5   public static void main(String[] args) {
     6     BufferedReader br = new BufferedReader(  new InputStreamReader(System.in) );
     7     String s = null;
     8 
     9   try
    10   {
    11     PrintWriter log = new PrintWriter( new FileWriter("D://javalearning//MYIO//log4j.txt",true) );
    12     s = br.readLine();
    13     while(s!=null){
    14       if (s.equalsIgnoreCase("exit")) break;
    15        System.out.println(s.toUpperCase());
    16        log.println("--------");
    17        log.println(s.toUpperCase());
    18        log.flush();
    19     }
    20     log.println("=="+new Date()+"==");
    21     log.flush();
    22     log.close();
    23 
    24   }
    25   catch (IOException e)
    26   {
    27      e.printStackTrace();
    28   }
    29 }
    30 }
  • 相关阅读:
    bzoj-4433 小凸玩矩阵(二分图,二分+匈牙利)
    HDU-2255 奔小康赚大钱(二分图、km算法、模板)
    python queue和生产者和消费者模型
    python Events
    python递归锁与信号量
    python 线程锁
    python GIL锁
    python 守护进程
    python 继承式多线程
    python 多线程效果演示
  • 原文地址:https://www.cnblogs.com/jasonzeng888/p/5721317.html
Copyright © 2011-2022 走看看