保存进度!
This commit is contained in:
		@@ -0,0 +1,42 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2024-01-26 01:20:00
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /MultiThread/src/main/java/com/cpic/xim/thread/SuspendResumeThread.java
 | 
			
		||||
 * @Description: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2023} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.thread;
 | 
			
		||||
 | 
			
		||||
public class SuspendResumeThread implements Runnable
 | 
			
		||||
{
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            System.out.println("进入工作线程!");
 | 
			
		||||
 | 
			
		||||
            for (int i=0; i< 9999; i++ )
 | 
			
		||||
            {
 | 
			
		||||
                if ( Thread.currentThread().isInterrupted() )
 | 
			
		||||
                {
 | 
			
		||||
                    throw new InterruptedException();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                System.out.println( "工作线程计数:" + String.valueOf( i ) );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            System.out.println("工作线程结束!");
 | 
			
		||||
        }
 | 
			
		||||
        catch ( InterruptedException error )
 | 
			
		||||
        {
 | 
			
		||||
            System.out.println("工作线程被中断!");
 | 
			
		||||
        }
 | 
			
		||||
        catch ( ThreadDeath error )
 | 
			
		||||
        {
 | 
			
		||||
            System.out.println("工作线程被stop!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -14,7 +14,6 @@ public class MyThread extends Thread
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run()
 | 
			
		||||
    {
 | 
			
		||||
        super.run();
 | 
			
		||||
 | 
			
		||||
        System.out.println("我是工作线程:" + String.valueOf(Thread.currentThread().threadId()) );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user