提交 5fe29cdb authored 作者: 杨雪's avatar 杨雪

雪花算法、多线程雪花算法、改变ID中序列号位数的实现

上级
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/notes.iml" filepath="$PROJECT_DIR$/notes.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisUIOptions">
<option name="GROUP_BY_SEVERITY" value="true" />
</component>
<component name="ChangeListManager">
<list default="true" id="19aa8773-d8da-4ea0-82d8-190ba864abeb" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DefaultGradleProjectSettings">
<option name="isMigrated" value="true" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/multithread/MyRunnable.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="38" column="41" selection-start-line="38" selection-start-column="41" selection-end-line="38" selection-end-column="41" />
<folding>
<element signature="e#538#539#0" expanded="true" />
<element signature="e#580#581#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/multithread/TestThreadPool.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="10" column="24" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/multithread/SnowFake.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="231">
<caret line="29" column="48" selection-start-line="29" selection-start-column="48" selection-end-line="29" selection-end-column="48" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/increasethenumber/IncreaseTheNumberOfID.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="441">
<caret line="63" column="9" lean-forward="true" selection-start-line="63" selection-start-column="9" selection-end-line="63" selection-end-column="9" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/notes.iml">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/note.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor />
<second_editor />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/Demo.java" />
<option value="$PROJECT_DIR$/src/timeStamp.java" />
<option value="$PROJECT_DIR$/../homework/snow/src/SnowFlow.java" />
<option value="$PROJECT_DIR$/src/snowfake.java" />
<option value="$PROJECT_DIR$/src/Person.java" />
<option value="$PROJECT_DIR$/src/test.java" />
<option value="$PROJECT_DIR$/src/MultiThread.java" />
<option value="$PROJECT_DIR$/src/SnowFlowThread.java" />
<option value="$PROJECT_DIR$/src/MyCallable.java" />
<option value="$PROJECT_DIR$/src/SnowFlow.java" />
<option value="$PROJECT_DIR$/src/IncreaseTheNumberOfID.java" />
<option value="$PROJECT_DIR$/src/MyRunnable.java" />
<option value="$PROJECT_DIR$/src/SnowFake.java" />
<option value="$PROJECT_DIR$/src/TestThreadPool.java" />
<option value="$PROJECT_DIR$/src/SimpleSnowFake/SnowFake.java" />
<option value="$PROJECT_DIR$/src/simplesnowfake/SnowFake.java" />
<option value="$PROJECT_DIR$/src/multithread/TestThreadPool.java" />
<option value="$PROJECT_DIR$/src/multithread/MyRunnable.java" />
<option value="$PROJECT_DIR$/src/multithread/SnowFake.java" />
<option value="$PROJECT_DIR$/src/increasethenumber/IncreaseTheNumberOfID.java" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="localRepository" value="D:\mvrnp" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="40" />
<option name="y" value="13" />
<option name="width" value="1937" />
<option name="height" value="989" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="Reflect" type="b2602c69:ProjectViewProjectNode" />
<item name="Reflect" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="Reflect" type="b2602c69:ProjectViewProjectNode" />
<item name="Reflect" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="preferences.intentionPowerPack" />
</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="SimpleSnowFake" />
</key>
</component>
<component name="RestServicesNavigator">
<treeState>
<expand />
<select />
</treeState>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Application.IncreaseTheNumberOfID">
<configuration name="IncreaseTheNumberOfID" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="increasethenumber.IncreaseTheNumberOfID" />
<module name="notes" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="MyCallable" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="MyCallable" />
<module name="notes" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Myrunnable" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Myrunnable" />
<module name="notes" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="SnowFlow" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="SnowFlow" />
<module name="notes" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TestThreadPool" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="multithread.TestThreadPool" />
<module name="notes" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<module name="notes" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType" factoryName="Kotlin script">
<module name="notes" />
<option name="filePath" />
<option name="vmParameters" />
<option name="alternativeJrePath" />
<option name="programParameters" />
<option name="passParentEnvs" value="true" />
<option name="workingDirectory" />
<option name="isAlternativeJrePathEnabled" value="false" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
<option name="filePath" />
<option name="vmParameters" />
<option name="alternativeJrePath" />
<option name="programParameters" />
<option name="passParentEnvs" value="true" />
<option name="workingDirectory" />
<option name="isAlternativeJrePathEnabled" value="false" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.IncreaseTheNumberOfID" />
<item itemvalue="Application.TestThreadPool" />
<item itemvalue="Application.SnowFlow" />
<item itemvalue="Application.Myrunnable" />
<item itemvalue="Application.MyCallable" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="19aa8773-d8da-4ea0-82d8-190ba864abeb" name="Default Changelist" comment="" />
<created>1587431963399</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1587431963399</updated>
<workItem from="1587431967495" duration="2595000" />
<workItem from="1590356566551" duration="9847000" />
<workItem from="1590498531711" duration="14936000" />
<workItem from="1590649834137" duration="599000" />
<workItem from="1590714088108" duration="2162000" />
<workItem from="1590719722288" duration="596000" />
<workItem from="1590735608738" duration="1739000" />
<workItem from="1590991278990" duration="14768000" />
<workItem from="1591061512962" duration="1193000" />
<workItem from="1591062751113" duration="22953000" />
<workItem from="1591109007404" duration="9057000" />
<workItem from="1591163512356" duration="11299000" />
<workItem from="1591194005347" duration="7813000" />
<workItem from="1591225238040" duration="789000" />
<workItem from="1591226268314" duration="10864000" />
<workItem from="1591241336943" duration="6763000" />
<workItem from="1591252631642" duration="468000" />
<workItem from="1591253268935" duration="5404000" />
<workItem from="1591326751534" duration="5193000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="129038000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2600536" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Designer" order="2" />
<window_info id="UI Designer" order="3" />
<window_info id="Favorites" order="4" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.3281471" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49731544" visible="true" weight="0.21216407" />
<window_info anchor="bottom" id="Debug" order="3" sideWeight="0.49798658" weight="0.27157003" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info anchor="bottom" id="Docker" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.5026846" side_tool="true" weight="0.31914893" />
<window_info anchor="bottom" id="Statistic" order="10" />
<window_info anchor="bottom" id="Database Changes" order="11" />
<window_info anchor="bottom" id="Version Control" order="12" />
<window_info anchor="bottom" id="Messages" order="13" weight="0.056577086" />
<window_info anchor="bottom" id="MyBatis Log" order="14" />
<window_info anchor="bottom" id="Tail" order="15" />
<window_info anchor="bottom" id="Duplicates" order="16" weight="0.069503546" />
<window_info anchor="bottom" id="Packages" order="17" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Maven" order="3" />
<window_info anchor="right" id="Palette" order="4" />
<window_info anchor="right" id="Word Book" order="5" side_tool="true" />
<window_info anchor="right" id="Database" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="RestServices" order="8" weight="0.23927614" />
<window_info anchor="right" id="Coverage" order="9" side_tool="true" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/Reflect$TestThreadPool.ic" NAME="TestThreadPool Coverage Results" MODIFIED="1591249222455" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
<SUITE FILE_PATH="coverage/Reflect$timeStamp.ic" NAME="timeStamp Coverage Results" MODIFIED="1590368769888" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../homework/snow/src/SnowFlow.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret selection-end-line="137" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://C:/Program Files/Java/jdk1.8.0_181/src.zip!/java/util/concurrent/ExecutorService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="21">
<caret line="263" column="34" selection-start-line="263" selection-start-column="30" selection-end-line="263" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="jar://C:/Program Files/Java/jdk1.8.0_181/src.zip!/java/util/Arrays.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="140">
<caret line="3209" selection-start-line="3209" selection-end-line="3209" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/SnowFlowThread.java" />
<entry file="file://$PROJECT_DIR$/src/Person.java" />
<entry file="file://$PROJECT_DIR$/src/test.java" />
<entry file="file://$PROJECT_DIR$/src/MultiThread.java" />
<entry file="file://$PROJECT_DIR$/src/Demo.java" />
<entry file="file://$PROJECT_DIR$/src/SnowFlow.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="154">
<caret line="115" column="34" selection-start-line="115" selection-end-line="116" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/multithread/timeStamp.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/simplesnowfake/SnowFake.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1638">
<caret line="83" column="37" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/multithread/TestThreadPool.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="10" column="24" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/multithread/MyRunnable.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="38" column="41" selection-start-line="38" selection-start-column="41" selection-end-line="38" selection-end-column="41" />
<folding>
<element signature="e#538#539#0" expanded="true" />
<element signature="e#580#581#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/multithread/SnowFake.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="231">
<caret line="29" column="48" selection-start-line="29" selection-start-column="48" selection-end-line="29" selection-end-column="48" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/increasethenumber/IncreaseTheNumberOfID.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="441">
<caret line="63" column="9" lean-forward="true" selection-start-line="63" selection-start-column="9" selection-end-line="63" selection-end-column="9" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/notes.iml">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/note.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor />
<second_editor />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>Reflect</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
单线程:
序号位数为12位时:31%
序号位数为13位时:31%
序号位数为14位时:31%
序号位数为15位时:85%
序号位数为16位时:98%
```chart
n12,31
n13,31
n14,31
n15,85
n16,98
type: line
title: 单线程:CPU与序列号位数之间的关系
x.title: 序列号位数
y.title: CPU使用率
y.suffix: %
```
* * *
多线程:
5个线程:
序号位数为12位时:75%
序号位数为16位时:98%
4个线程
序号位数为12位时:78%
序号位数为16位时:95%
3个线程
序号位数为12位时:74%
序号位数为16位时:95%
2个线程
序号位数为12位时:67%
序号位数为16位时:88%
```chart
,Two,Three,Four,Five
n12,67,74,78,75
n16,88,95,95,98
type: line
title: 多线程:CPU与序列号位数之间的关系
x.title: 序列号位数
y.title: CPU使用率
y.suffix: %
```
* * *
```chart
,十万,百万,千万
n12,3329,3720,3932
n13,5700,7253,7779
n14,7542,14311,14721
n15,7685,25183,28459,
n16,9347,47022,51143
type: line
title: QPS与序列号位数、生成ID个数之间的关系
x.title: 序列号位数
y.title: QPS
y.suffix: *1000
X.suffix: 位
```
```chart
,百万,千万
t2,3633,3897
t3,3800,3862
t4,3600,3936
t5,3634,3945
type: line
title: QPS与线程数、生成id个数之间的关系
x.title: 线程数
y.title: QPS
y.suffix: *1000
```
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
package increasethenumber;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author 杨雪
*/
public class IncreaseTheNumberOfID {
/**
* 当前时间戳
*/
private static final long START_TIMESTAMP = 1590368867576L;
/**
*机器编码在ID中占得位数
*/
private static final long WORK_ID = 0L;
private long serialNumber = 0L;
private long lastTimestamp = 0L;
public long newId(){
long currentTimestamp = System.currentTimeMillis();
if (currentTimestamp < lastTimestamp){
throw new RuntimeException("时钟回拨");
}
if (currentTimestamp == lastTimestamp){
if (serialNumber < 32767L){
serialNumber += 1;
}
if (serialNumber == 32767L){
serialNumber = 0L;
}
if (serialNumber == 0L){
while (lastTimestamp >= currentTimestamp){
currentTimestamp = System.currentTimeMillis();
}
lastTimestamp = currentTimestamp;
}
}else {
currentTimestamp = System.currentTimeMillis();
serialNumber = 0L;
lastTimestamp = currentTimestamp;
}
return ((currentTimestamp-START_TIMESTAMP) << 22L)
|(WORK_ID << 15L)
|serialNumber ;
}
public static void main(String[] args) {
IncreaseTheNumberOfID increaseTheNumberOfID = new IncreaseTheNumberOfID();
List<Long> idList = new ArrayList();
long start = System.currentTimeMillis();
for (int i = 0; i<1000_000; i++){
long id = increaseTheNumberOfID.newId();
}
long end = System.currentTimeMillis();
for (int i = 0; i<1000_000; i++){
idList.add(increaseTheNumberOfID.newId());
}
Set<Long> idSet = new HashSet<>(idList);
int num = 0;
long nowId;
/* for (int j=1; j<idList.size(); j++){
nowId = idList.get(j);
if (nowId > idList.get(j-1)){
num ++;
}
}
System.out.println("满足递增比较的次数:"+num);
System.out.println(" ");*/
System.out.println("总共生成id数:"+idList.size()
+" 花费时间为:"+(end-start)+"ms"
+" qps="+1000_000/(end-start)*1000);
System.out.println(" ");
System.out.println("list的id数量:"+idList.size()
+" set的id数量"+idSet.size());
}
}
package multithread;
import multithread.SnowFake;
import java.util.concurrent.atomic.AtomicLong;
public class MyRunnable implements Runnable {
private static final long START_TIMESTAMP = 1590368867576L;
/**
*机器编码在ID中占得位数
*/
private static final long WORK_ID = 0L;
private long serialNumber = 0L;
private long lastTimestamp = 0L;
private String taskNum;
private SnowFake snowFake;
private AtomicLong atomicLong;
public MyRunnable(SnowFake snowFake) {
this.snowFake = snowFake;
}
public MyRunnable(SnowFake snowFake, AtomicLong atomicLong) {
this.snowFake = snowFake;
this.atomicLong = atomicLong;
}
public MyRunnable() {
}
@Override
public void run() {
for (int i=0; i<=1000_000_000/2; i++) {
snowFake.newId();
atomicLong.incrementAndGet();
}
}
}
package multithread;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author 杨雪
*/
public class SnowFake {
/**
* 开始时间截(这个可以自己使用已经流逝的时间,我用的是自己写代码时的实际时间)
*/
private static final long START_STAMP = 1590368867576L;
/**
* 数据中心在id中占的位数
*/
private static final long DATA_CENTER_ID = 5L;
/**
* 机器码在id中占的位数
*/
private static final long MACHINE_ID = 1L;
/**
* 序列号在id中占得位数
*/
private static final long SERIAL_NUMBER = 16L;
/**
* 序列号最大值4095
*/
private static final long MAX_SERIAL_NUMBER = -1L ^ -1L << SERIAL_NUMBER;
private long dataCenter = 0L;
private long machineId = 0L;
private long serialNumber = 0L;
/**
* 上次生成ID的时间截
*/
private long lastTimestamp = 0L;
/**
* 数据标识id向左移17位(12+5)
*/
private final long datacenterIdLeft = SERIAL_NUMBER + MACHINE_ID;
/**
* 时间截向左移22位(5+5+12)
*/
private final long timestampLeftShift = SERIAL_NUMBER + MACHINE_ID + DATA_CENTER_ID;
public long getCurrentTimestamp() {
return System.currentTimeMillis();
}
public synchronized long newId() {
long currentTimestamp = getCurrentTimestamp();
if (currentTimestamp < lastTimestamp) {
throw new RuntimeException(
"出现时钟回拨异常");
}
if (currentTimestamp == lastTimestamp) {
serialNumber = (serialNumber + 1) & MAX_SERIAL_NUMBER;
if (serialNumber == 0L) {
while (lastTimestamp >= currentTimestamp) {
currentTimestamp = getCurrentTimestamp();
}
}
} else {
currentTimestamp = getCurrentTimestamp();
serialNumber = 0L;
}
lastTimestamp = currentTimestamp;
long l = ((currentTimestamp - START_STAMP) << timestampLeftShift)
| dataCenter << datacenterIdLeft
| (machineId << SERIAL_NUMBER)
| serialNumber;
return l;
}
}
package multithread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
public class TestThreadPool {
public static void main(String[] args) {
AtomicLong atomicLong = new AtomicLong(0);
int taskSize = 2;
// 创建一个线程池
ExecutorService pool = Executors.newFixedThreadPool(taskSize);
long start = System.currentTimeMillis();
SnowFake snowFake = new SnowFake();
for (int i =0; i <taskSize; i++){
pool.submit(new MyRunnable(snowFake, atomicLong));
}
while (atomicLong.get()!= 1000_000_000){
}
long end = System.currentTimeMillis();
System.out.println("qps:"+1000_000_000/(end-start)*1000);
}
}
package simplesnowfake;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author 杨雪
*/
public class SnowFake {
/**
* 开始时间截(这个可以自己使用已经流逝的时间,我用的是自己写代码时的实际时间)
*/
private static final long START_STAMP = 1590368867576L;
/**
* 数据中心在id中占的位数
*/
private static final long DATA_CENTER_ID = 5L ;
/**
* 机器码在id中占的位数
*/
private static final long MACHINE_ID = 1L;
/**
* 序列号在id中占得位数
*/
private static final long SERIAL_NUMBER = 16L;
/**
* 序列号最大值4095
*/
private static final long MAX_SERIAL_NUMBER = -1L ^ -1L << SERIAL_NUMBER;
private long dataCenter =0L;
private long machineId = 0L;
private long serialNumber = 0L;
/**
* 上次生成ID的时间截
*/
private long lastTimestamp = 0L;
/**
* 数据标识id向左移17位(12+5)
*/
private final long datacenterIdLeft = SERIAL_NUMBER + MACHINE_ID;
/**
* 时间截向左移22位(5+5+12)
*/
private final long timestampLeftShift = SERIAL_NUMBER + MACHINE_ID + DATA_CENTER_ID;
public long getCurrentTimestamp(){
return System.currentTimeMillis();
}
public synchronized long newId(){
long currentTimestamp = getCurrentTimestamp();
if (currentTimestamp < lastTimestamp){
throw new RuntimeException(
"出现时钟回拨异常");
}
if (currentTimestamp == lastTimestamp){
serialNumber =(serialNumber+1) & MAX_SERIAL_NUMBER;
if (serialNumber == 0L){
while(lastTimestamp >= currentTimestamp){
currentTimestamp = getCurrentTimestamp();
}
}
}else {
currentTimestamp = getCurrentTimestamp();
serialNumber = 0L;
}
lastTimestamp = currentTimestamp;
long l = ((currentTimestamp - START_STAMP) << timestampLeftShift)
| dataCenter << datacenterIdLeft
| (machineId << SERIAL_NUMBER)
| serialNumber;
return l;
}
public static void main(String[] args) {
SnowFake sf = new SnowFake();
List<Long> list = new ArrayList();
int i = 0;
long start = System.currentTimeMillis();
while (i <= 10_0000) {
i++;
long id = sf.newId();
}
long end = System.currentTimeMillis();
Set<Long> ids = new HashSet<>(list);
int num=1;
long nowId;
for (int i1=1;i1<list.size();i1++){
nowId = list.get(i1);
if(nowId>list.get(i1-1)){
num++;
}
}
System.out.println("满足递增比较的次数:"+num);
System.out.println("qps="+100000/(end-start)*1000);
System.out.println("总共生成"+ids.size()+"个ID,花费时间为"+(end - start)+"毫秒");
System.out.println(list.size());
System.out.println(ids.size());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论