refactor: 重构代码
This commit is contained in:
parent
44cb49b87a
commit
6058183f18
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/localTools/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/multithreading1/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/multithreading1/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/multithreading1/src/main/resources-filtered" charset="UTF-8" />
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/multithreading1/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>multithreading1</artifactId>
|
||||
<artifactId>localTools</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>multithreading1</name>
|
||||
<name>localTools</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle;
|
||||
package cn.bunny.starTrek;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
|
@ -1,11 +1,11 @@
|
|||
package thead.subtitle.video;
|
||||
package cn.bunny.video;
|
||||
|
||||
import cn.bunny.video.dao.Response;
|
||||
import cn.bunny.video.dao.VideoEntity;
|
||||
import cn.bunny.video.utils.HttpRequestUtils;
|
||||
import cn.bunny.video.utils.SystemControlUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
import thead.subtitle.video.dao.Response;
|
||||
import thead.subtitle.video.dao.VideoEntity;
|
||||
import thead.subtitle.video.utils.HttpRequestUtils;
|
||||
import thead.subtitle.video.utils.SystemControlUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
|
@ -1,12 +1,12 @@
|
|||
package thead.subtitle.video;
|
||||
package cn.bunny.video;
|
||||
|
||||
import cn.bunny.video.dao.Response;
|
||||
import cn.bunny.video.dao.VideoEntity;
|
||||
import cn.bunny.video.utils.HttpRequestUtils;
|
||||
import cn.bunny.video.utils.SystemControlUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import thead.subtitle.video.dao.Response;
|
||||
import thead.subtitle.video.dao.VideoEntity;
|
||||
import thead.subtitle.video.utils.HttpRequestUtils;
|
||||
import thead.subtitle.video.utils.SystemControlUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle.video.dao;
|
||||
package cn.bunny.video.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle.video.dao;
|
||||
package cn.bunny.video.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle.video.dao;
|
||||
package cn.bunny.video.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle.video.utils;
|
||||
package cn.bunny.video.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
|
@ -1,4 +1,4 @@
|
|||
package thead.subtitle.video.utils;
|
||||
package cn.bunny.video.utils;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.profile.StackProfiler;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic;
|
||||
package atomic;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic.reference;
|
||||
package atomic.reference;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.atomic.reference;
|
||||
package atomic.reference;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package feture.feture;
|
||||
package feture;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
public class MyFutureTask {
|
||||
public class MyFutureTask01 {
|
||||
public static void main(String[] args) {
|
||||
FutureTask<Integer> futureTask = new FutureTask<>(new Callable<>() {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package feture.feture_2;
|
||||
package feture;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
public class MyFutureTask {
|
||||
public class MyFutureTask02 {
|
||||
public static void main(String[] args) {
|
||||
FutureTask<Integer> futureTask = new FutureTask<>(new Callable<>() {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.jmh;
|
||||
package jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.profile.StackProfiler;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
|
||||
import lombok.Getter;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.stream;
|
||||
package stream;
|
||||
|
||||
public class StreamExample23 {
|
||||
public static void main(String[] args) {
|
|
@ -1,4 +1,4 @@
|
|||
package tools;
|
||||
package thead;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package thead.thread_9;
|
||||
|
||||
import tools.Box;
|
||||
import thead.Box;
|
||||
|
||||
public class MyThread extends Thread {
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package thead.thread_9;
|
||||
|
||||
import tools.Box;
|
||||
import thead.Box;
|
||||
|
||||
public class Test1 {
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe0;
|
||||
package thread_safe.safe0;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe0;
|
||||
package thread_safe.safe0;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe1;
|
||||
package thread_safe.safe1;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe2;
|
||||
package thread_safe.safe2;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe3;
|
||||
package thread_safe.safe3;
|
||||
|
||||
public class Run {
|
||||
public static void main(String[] args) {
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe4;
|
||||
package thread_safe.safe4;
|
||||
|
||||
public class SynchronizedMethodLocakObject {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe4;
|
||||
package thread_safe.safe4;
|
||||
|
||||
public class SynchronizedMethodLocakObject2 {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe5;
|
||||
package thread_safe.safe5;
|
||||
|
||||
// 在多线程编程中,synchronized 关键字可以确保一个线程在执行某个方法时,其他线程无法同时访问被同步的方法,从而避免多个线程同时修改共享数据的问题。
|
||||
// 脏读(Dirty Read)指的是一个线程读取到另一个线程还未提交的修改数据,这种数据在另一个线程最终提交或者回滚后可能会发生变化,因此是不可靠的。
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe6;
|
||||
package thread_safe.safe6;
|
||||
|
||||
/**
|
||||
* sychronized 锁重入指的是一个线程在获得一个锁之后,可以再次进入该锁(即再次获取锁)而不会发生死锁。
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe7;
|
||||
package thread_safe.safe7;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe8;
|
||||
package thread_safe.safe8;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package thread_1.safe9;
|
||||
package thread_safe.safe9;
|
||||
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
Loading…
Reference in New Issue