refactor: 重构代码

This commit is contained in:
Bunny 2025-01-21 21:39:23 +08:00
parent 44cb49b87a
commit 6058183f18
79 changed files with 96 additions and 89 deletions

View File

@ -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" />

View File

@ -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" />

View File

@ -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>

View File

@ -1,4 +1,4 @@
package thead.subtitle;
package cn.bunny.starTrek;
import java.io.File;
import java.io.IOException;

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,4 @@
package thead.subtitle.video.dao;
package cn.bunny.video.dao;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package thead.subtitle.video.dao;
package cn.bunny.video.dao;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package thead.subtitle.video.dao;
package cn.bunny.video.dao;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package thead.subtitle.video.utils;
package cn.bunny.video.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;

View File

@ -1,4 +1,4 @@
package thead.subtitle.video.utils;
package cn.bunny.video.utils;
import lombok.extern.slf4j.Slf4j;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.profile.StackProfiler;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import java.util.concurrent.CountDownLatch;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import java.util.concurrent.PriorityBlockingQueue;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import java.util.concurrent.LinkedBlockingQueue;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic;
package atomic;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic.reference;
package atomic.reference;
import java.util.concurrent.TimeUnit;

View File

@ -1,4 +1,4 @@
package cn.bunny.atomic.reference;
package atomic.reference;
import lombok.Getter;

View File

@ -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<>() {

View File

@ -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<>() {

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;

View File

@ -1,4 +1,4 @@
package cn.bunny.jmh;
package jmh;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.profile.StackProfiler;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.ArrayList;
import java.util.Collection;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.stream.Stream;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.stream.Stream;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.Comparator;
import java.util.Optional;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.Arrays;
import java.util.List;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import java.util.Arrays;
import java.util.List;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cn.bunny.stream;
package stream;
public class StreamExample23 {
public static void main(String[] args) {

View File

@ -1,4 +1,4 @@
package tools;
package thead;
import java.util.ArrayList;

View File

@ -1,6 +1,6 @@
package thead.thread_9;
import tools.Box;
import thead.Box;
public class MyThread extends Thread {
/**

View File

@ -1,6 +1,6 @@
package thead.thread_9;
import tools.Box;
import thead.Box;
public class Test1 {
public static void main(String[] args) {

View File

@ -1,4 +1,4 @@
package thread_1.safe0;
package thread_safe.safe0;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package thread_1.safe0;
package thread_safe.safe0;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package thread_1.safe1;
package thread_safe.safe1;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package thread_1.safe2;
package thread_safe.safe2;
import java.util.concurrent.atomic.AtomicInteger;

View File

@ -1,4 +1,4 @@
package thread_1.safe3;
package thread_safe.safe3;
public class Run {
public static void main(String[] args) {

View File

@ -1,4 +1,4 @@
package thread_1.safe4;
package thread_safe.safe4;
public class SynchronizedMethodLocakObject {

View File

@ -1,4 +1,4 @@
package thread_1.safe4;
package thread_safe.safe4;
public class SynchronizedMethodLocakObject2 {

View File

@ -1,4 +1,4 @@
package thread_1.safe5;
package thread_safe.safe5;
// 在多线程编程中synchronized 关键字可以确保一个线程在执行某个方法时其他线程无法同时访问被同步的方法从而避免多个线程同时修改共享数据的问题
// 脏读Dirty Read指的是一个线程读取到另一个线程还未提交的修改数据这种数据在另一个线程最终提交或者回滚后可能会发生变化因此是不可靠的

View File

@ -1,4 +1,4 @@
package thread_1.safe6;
package thread_safe.safe6;
/**
* sychronized 锁重入指的是一个线程在获得一个锁之后可以再次进入该锁即再次获取锁而不会发生死锁

View File

@ -1,4 +1,4 @@
package thread_1.safe7;
package thread_safe.safe7;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package thread_1.safe8;
package thread_safe.safe8;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package thread_1.safe9;
package thread_safe.safe9;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;

View File

@ -22,6 +22,7 @@
<modules>
<module>multithreading1</module>
<module>multithreading_init</module>
<module>localTools</module>
</modules>
<scm>
<connection/>