chapter21n5.java

来自「JAVA源代码程序aashjkjhkjhkjhjkhkj」· Java 代码 · 共 67 行

JAVA
67
字号
/** * * demonstration of threads version II * * Written by: Roger Garside * * First Written: 6/Feb/97  * Last Rewritten: 6/Feb/97 * */class ProcessString2 implements Runnable    {    private String originalString ;    public ProcessString2(String string)	{	originalString = string ;	Thread thisThread = new Thread(this) ;	thisThread.start() ;	} // end of constructor method    public void run()	{	int offset = 0 ;	while (true)	    {	    String s = originalString.substring(0, offset) +		Character.toUpperCase(originalString.charAt(offset))		+ originalString.substring(offset + 1) ;	    System.out.println("**" + s + "**") ;	    offset++ ;	    if (offset == originalString.length())		offset = 0 ;	    try {		Thread.sleep(1000) ;		}	    catch (InterruptedException e)		{		}	    }	} // end of method run    } // end of class ProcessString2public class Chapter21n5    {    public static void main(String[] args)	{	ProcessString2 p1 = new ProcessString2("lancaster") ;	while (true)	    {	    System.out.println("Hello again") ;	    try {		Thread.sleep(5000) ;		}	    catch (InterruptedException e)		{		}	    }	} // end of method main    } // end of class Chapter21n5

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?