zoukankan      html  css  js  c++  java
  • 16周作业

    题目一

    package com;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class thread implements Runnable{
        Date date;
        public void run() {
            while(true){
                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
                String time = sdf.format(date);
                System.out.println(time);
                try{
                    Thread.sleep(1000);
                }catch(InterruptedException e){
                    System.out.println(e);
                }
            }
            
            
      
        }
    }
    package com;
    
    import java.util.Scanner;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            Thread t=new Thread(new thread() );
            t.start();
        }
    
    }

     题目二

    package com;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Scanner;
    public class thread implements Runnable{
        Scanner s=new Scanner(System.in);
        int flag;
        public void run() {
            while(true){
                System.out.println("请输入数字");
                int c=s.nextInt();
                int a=(int)(Math.random()*100);
                if(c>=a){
                    System.out.println("你的数字猜大了");
                }else if(c<a)
                    System.out.println("你猜的数字小了,");
                else System.out.println("恭喜你,猜对了");
             //   System.out.println(a);
                try{
                    Thread.sleep(1000);
                  
                    
                }catch(InterruptedException e){
                    System.out.println(e);
                }
           
            }
            
            
      
        }
    }
    package com;
    
    import java.util.Scanner;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            Thread t=new Thread(new thread() );
            t.start();
        }
    
    }

  • 相关阅读:
    java当前时间
    @Repository、@Service、@Controller 和 @Component
    spring mvc controller间跳转 重定向 传参
    MVC思想
    AJAX
    MySQL优化大总结
    MySQL数据库优化
    java JDBM2 的几个简单实例
    集群环境下如何防止定时任务重复执行?
    Java应用集群下的定时任务处理方案(mysql)
  • 原文地址:https://www.cnblogs.com/chenxiangyuu/p/12076818.html
Copyright © 2011-2022 走看看