zoukankan      html  css  js  c++  java
  • 16

    题目1

    package com;
    
    import java.awt.Graphics;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class thread implements Runnable{
        Thread clockThread;
        Date date;
        public void start() {
            if(clockThread==null){
                clockThread=new Thread(); 
                clockThread.start();
        }
            }
        
        public void run() {
            while(clockThread!=null){
                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
                String time = sdf.format(date);
                System.out.println(time);        
            }
            try{
                clockThread.sleep(1000);
            }catch(InterruptedException e){
                System.out.println(e);
            }
        }
    }


    package com;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            thread t=new thread();
            t.start();
            t.run();
        }
    
    }

     题目二

    package com;
    
    import java.awt.Graphics;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Scanner;
    public class thread implements Runnable{
        Thread clockThread;
        public void start() {
            if(clockThread==null){
                clockThread=new Thread(); 
                clockThread.start();
        }
            }
        
        public void run() {
            Scanner s=new Scanner(System.in);
            System.out.println("input");
            int c=s.nextInt();
            int ran=((int)Math.random()*100);
            
            
                if(c>ran){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
        
            
            try{
                clockThread.sleep(4000000);
            }catch(InterruptedException e){
                System.out.println(e);
            }
        }
    }

  • 相关阅读:
    调用https接口 报错:unable to find valid certification path
    POI生成Excel
    杂七杂八记录
    maven 打jar 包 pom.xml配置
    IDEA 全局修改项目版本
    Spring AOP的内部调用问题
    redis 中文乱码
    windows redis cluster 配置
    spring事物失效场景
    Mybatis常用示例
  • 原文地址:https://www.cnblogs.com/chenxiangyuu/p/12060870.html
Copyright © 2011-2022 走看看