Topic 1: write an application using Java multi-threading mechanism to achieve synchronization output time display.
First, the source
TimeThread.java
/ ** use Java multithreading mechanism to achieve synchronization output time display. * */ package cn.edu.ccut.w1219t1; import java.util.Date; public class TimeThread the extends the Thread { // override method allows a thread of execution run time output public void run () { Date Date; while(true){ date = new Date(); System.out.println (DATE); // current system time of the output acquired the try { SLEEP ( 1000); // every second sleep time } the catch (InterruptedException E) { e.printStackTrace (); } } } public static void main(String[] args) { TimeThread time = new TimeThread(); time.start(); } }
Second, the success Screenshots
Topic 2: write an application using Java multi-threading mechanism to achieve guessing game (an integer between 0 to 100 range of random numbers).
First, the source
Second, the success Screenshots