esoe
2 years ago
80 changed files with 7104 additions and 0 deletions
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- You may freely edit this file. See commented blocks below for --> |
||||
<!-- some examples of how to customize the build. --> |
||||
<!-- (If you delete it and reopen the project it will be recreated.) --> |
||||
<!-- By default, only the Clean and Build commands use this build script. --> |
||||
<!-- Commands such as Run, Debug, and Test only use this build script if --> |
||||
<!-- the Compile on Save feature is turned off for the project. --> |
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> |
||||
<!-- in the project's Project Properties dialog box.--> |
||||
<project name="GazStation" default="default" basedir="."> |
||||
<description>Builds, tests, and runs the project GazStation.</description> |
||||
<import file="nbproject/build-impl.xml"/> |
||||
<!-- |
||||
|
||||
There exist several targets which are by default empty and which can be |
||||
used for execution of your tasks. These targets are usually executed |
||||
before and after some main targets. They are: |
||||
|
||||
-pre-init: called before initialization of project properties |
||||
-post-init: called after initialization of project properties |
||||
-pre-compile: called before javac compilation |
||||
-post-compile: called after javac compilation |
||||
-pre-compile-single: called before javac compilation of single file |
||||
-post-compile-single: called after javac compilation of single file |
||||
-pre-compile-test: called before javac compilation of JUnit tests |
||||
-post-compile-test: called after javac compilation of JUnit tests |
||||
-pre-compile-test-single: called before javac compilation of single JUnit test |
||||
-post-compile-test-single: called after javac compilation of single JUunit test |
||||
-pre-jar: called before JAR building |
||||
-post-jar: called after JAR building |
||||
-post-clean: called after cleaning build products |
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.) |
||||
|
||||
Example of inserting an obfuscator after compilation could look like this: |
||||
|
||||
<target name="-post-compile"> |
||||
<obfuscate> |
||||
<fileset dir="${build.classes.dir}"/> |
||||
</obfuscate> |
||||
</target> |
||||
|
||||
For list of available properties check the imported |
||||
nbproject/build-impl.xml file. |
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets. |
||||
The targets of interest are: |
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation |
||||
-init-macrodef-junit: defines macro for junit execution |
||||
-init-macrodef-debug: defines macro for class debugging |
||||
-init-macrodef-java: defines macro for class execution |
||||
-do-jar: JAR building |
||||
run: execution of project |
||||
-javadoc-build: Javadoc generation |
||||
test-report: JUnit report generation |
||||
|
||||
An example of overriding the target for project execution could look like this: |
||||
|
||||
<target name="run" depends="GazStation-impl.jar"> |
||||
<exec dir="bin" executable="launcher.exe"> |
||||
<arg file="${dist.jar}"/> |
||||
</exec> |
||||
</target> |
||||
|
||||
Notice that the overridden target depends on the jar target and not only on |
||||
the compile target as the regular run target does. Again, for a list of available |
||||
properties which you can use, check the target you are overriding in the |
||||
nbproject/build-impl.xml file. |
||||
|
||||
--> |
||||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0 |
||||
X-COMMENT: Main-Class will be added automatically by build |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=9cd5ec1b |
||||
build.xml.script.CRC32=76050ae8 |
||||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48 |
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
nbproject/build-impl.xml.data.CRC32=9cd5ec1b |
||||
nbproject/build-impl.xml.script.CRC32=84c4fcda |
||||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
compile.on.save=true |
||||
user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> |
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> |
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> |
||||
<group> |
||||
<file>file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/Car.java</file> |
||||
<file>file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/GazProducer.java</file> |
||||
<file>file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/FilingColumn.java</file> |
||||
</group> |
||||
</open-files> |
||||
</project-private> |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
annotation.processing.enabled=true |
||||
annotation.processing.enabled.in.editor=false |
||||
annotation.processing.processor.options= |
||||
annotation.processing.processors.list= |
||||
annotation.processing.run.all.processors=true |
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
||||
build.classes.dir=${build.dir}/classes |
||||
build.classes.excludes=**/*.java,**/*.form |
||||
# This directory is removed when the project is cleaned: |
||||
build.dir=build |
||||
build.generated.dir=${build.dir}/generated |
||||
build.generated.sources.dir=${build.dir}/generated-sources |
||||
# Only compile against the classpath explicitly listed here: |
||||
build.sysclasspath=ignore |
||||
build.test.classes.dir=${build.dir}/test/classes |
||||
build.test.results.dir=${build.dir}/test/results |
||||
# Uncomment to specify the preferred debugger connection transport: |
||||
#debug.transport=dt_socket |
||||
debug.classpath=\ |
||||
${run.classpath} |
||||
debug.test.classpath=\ |
||||
${run.test.classpath} |
||||
# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar |
||||
dist.archive.excludes= |
||||
# This directory is removed when the project is cleaned: |
||||
dist.dir=dist |
||||
dist.jar=${dist.dir}/GazStation.jar |
||||
dist.javadoc.dir=${dist.dir}/javadoc |
||||
excludes= |
||||
includes=** |
||||
jar.compress=false |
||||
javac.classpath= |
||||
# Space-separated list of extra javac options |
||||
javac.compilerargs= |
||||
javac.deprecation=false |
||||
javac.external.vm=true |
||||
javac.processorpath=\ |
||||
${javac.classpath} |
||||
javac.source=1.8 |
||||
javac.target=1.8 |
||||
javac.test.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
javac.test.processorpath=\ |
||||
${javac.test.classpath} |
||||
javadoc.additionalparam= |
||||
javadoc.author=false |
||||
javadoc.encoding=${source.encoding} |
||||
javadoc.noindex=false |
||||
javadoc.nonavbar=false |
||||
javadoc.notree=false |
||||
javadoc.private=false |
||||
javadoc.splitindex=true |
||||
javadoc.use=true |
||||
javadoc.version=false |
||||
javadoc.windowtitle= |
||||
main.class=gazstation.MainClass |
||||
manifest.file=manifest.mf |
||||
meta.inf.dir=${src.dir}/META-INF |
||||
mkdist.disabled=false |
||||
platform.active=default_platform |
||||
run.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
# Space-separated list of JVM arguments used when running the project. |
||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. |
||||
# To set system properties for unit tests define test-sys-prop.name=value: |
||||
run.jvmargs= |
||||
run.test.classpath=\ |
||||
${javac.test.classpath}:\ |
||||
${build.test.classes.dir} |
||||
source.encoding=UTF-8 |
||||
src.dir=src |
||||
test.src.dir=test |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.java.j2seproject</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> |
||||
<name>GazStation</name> |
||||
<source-roots> |
||||
<root id="src.dir"/> |
||||
</source-roots> |
||||
<test-roots> |
||||
<root id="test.src.dir"/> |
||||
</test-roots> |
||||
</data> |
||||
</configuration> |
||||
</project> |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation; |
||||
|
||||
import java.util.Random; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class Car extends Thread{ |
||||
public int tank; |
||||
private int max = 40; |
||||
public String name; |
||||
|
||||
@Override |
||||
public void run() { |
||||
while(true){ |
||||
fuel(); |
||||
try {Thread.sleep(1000);} catch (InterruptedException ex) {} |
||||
int fuel = new Random().nextInt(40); |
||||
tank -= fuel; |
||||
System.out.println(name + ": израсходовал " + fuel + " л. Объем топлива: " + tank); |
||||
} |
||||
} |
||||
|
||||
public Car(String name) { |
||||
this.name = name; |
||||
this.tank = new Random().nextInt(max-20); |
||||
} |
||||
|
||||
public void fuel(){ |
||||
int fuel = max - tank; |
||||
boolean res = GazStation.getState().column1.getFuel(fuel); |
||||
if(!res) { |
||||
System.out.println(name + ": не достаточно топлива. Ожидает."); |
||||
|
||||
try {Thread.sleep(2000);} catch (InterruptedException ex) {} |
||||
fuel(); |
||||
}else { |
||||
tank += fuel; |
||||
System.out.println("--------------------------" + name + ": заправил " + fuel + " л. Объем топлива: " + tank); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class FilingColumn { |
||||
|
||||
private int bigTank; |
||||
private boolean isOrder; |
||||
|
||||
public FilingColumn (){ |
||||
bigTank = new Random().nextInt(500); |
||||
isOrder = true; |
||||
} |
||||
|
||||
|
||||
public synchronized boolean getFuel(int fuel) { |
||||
if(isOrder){ |
||||
if(bigTank<fuel){ |
||||
isOrder = false; |
||||
GazStation.getState().callGazProducer(this); |
||||
return false; |
||||
} |
||||
bigTank -= fuel; |
||||
} |
||||
return isOrder; |
||||
} |
||||
|
||||
public synchronized void addFuel(int fuel){ |
||||
bigTank += fuel; |
||||
System.out.println("Объем цистерны: " + bigTank + " л."); |
||||
isOrder = true; |
||||
notifyAll(); |
||||
} |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class GazProducer extends Thread{ |
||||
private FilingColumn column; |
||||
|
||||
public GazProducer(FilingColumn column){ |
||||
this.column = column; |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
System.out.println("Бензовоз выехал"); |
||||
try {Thread.sleep(5000);} catch (InterruptedException ex) {} |
||||
synchronized(column){ |
||||
call(); |
||||
} |
||||
} |
||||
|
||||
void call() { |
||||
FilingColumn column = GazStation.getState().column1; |
||||
int fuel = new Random().nextInt(40)*100; |
||||
column.addFuel(fuel); |
||||
System.out.println("Бензовоз заправил цистерну: " + fuel + " л."); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class GazStation { |
||||
public FilingColumn column1 = new FilingColumn(); |
||||
private static GazStation station; |
||||
|
||||
|
||||
private GazStation(){} |
||||
|
||||
public static GazStation getState(){ |
||||
if(station==null) station = new GazStation(); |
||||
return station; |
||||
} |
||||
|
||||
public void callGazProducer(FilingColumn column){ |
||||
GazProducer gazProducer = new GazProducer(column); |
||||
System.out.println("Вызван бензовоз"); |
||||
gazProducer.start(); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MainClass { |
||||
|
||||
/** |
||||
* @param args the command line arguments |
||||
*/ |
||||
public static void main(String[] args) { |
||||
Car[] cars = new Car[10]; |
||||
for(int i =0 ; i<10 ; i++) { |
||||
cars[i] = new Car("Car№" + i); |
||||
} |
||||
for(Car car : cars) car.start(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- You may freely edit this file. See commented blocks below for --> |
||||
<!-- some examples of how to customize the build. --> |
||||
<!-- (If you delete it and reopen the project it will be recreated.) --> |
||||
<!-- By default, only the Clean and Build commands use this build script. --> |
||||
<!-- Commands such as Run, Debug, and Test only use this build script if --> |
||||
<!-- the Compile on Save feature is turned off for the project. --> |
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> |
||||
<!-- in the project's Project Properties dialog box.--> |
||||
<project name="GazStation2" default="default" basedir="."> |
||||
<description>Builds, tests, and runs the project GazStation2.</description> |
||||
<import file="nbproject/build-impl.xml"/> |
||||
<!-- |
||||
|
||||
There exist several targets which are by default empty and which can be |
||||
used for execution of your tasks. These targets are usually executed |
||||
before and after some main targets. They are: |
||||
|
||||
-pre-init: called before initialization of project properties |
||||
-post-init: called after initialization of project properties |
||||
-pre-compile: called before javac compilation |
||||
-post-compile: called after javac compilation |
||||
-pre-compile-single: called before javac compilation of single file |
||||
-post-compile-single: called after javac compilation of single file |
||||
-pre-compile-test: called before javac compilation of JUnit tests |
||||
-post-compile-test: called after javac compilation of JUnit tests |
||||
-pre-compile-test-single: called before javac compilation of single JUnit test |
||||
-post-compile-test-single: called after javac compilation of single JUunit test |
||||
-pre-jar: called before JAR building |
||||
-post-jar: called after JAR building |
||||
-post-clean: called after cleaning build products |
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.) |
||||
|
||||
Example of inserting an obfuscator after compilation could look like this: |
||||
|
||||
<target name="-post-compile"> |
||||
<obfuscate> |
||||
<fileset dir="${build.classes.dir}"/> |
||||
</obfuscate> |
||||
</target> |
||||
|
||||
For list of available properties check the imported |
||||
nbproject/build-impl.xml file. |
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets. |
||||
The targets of interest are: |
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation |
||||
-init-macrodef-junit: defines macro for junit execution |
||||
-init-macrodef-debug: defines macro for class debugging |
||||
-init-macrodef-java: defines macro for class execution |
||||
-do-jar: JAR building |
||||
run: execution of project |
||||
-javadoc-build: Javadoc generation |
||||
test-report: JUnit report generation |
||||
|
||||
An example of overriding the target for project execution could look like this: |
||||
|
||||
<target name="run" depends="GazStation2-impl.jar"> |
||||
<exec dir="bin" executable="launcher.exe"> |
||||
<arg file="${dist.jar}"/> |
||||
</exec> |
||||
</target> |
||||
|
||||
Notice that the overridden target depends on the jar target and not only on |
||||
the compile target as the regular run target does. Again, for a list of available |
||||
properties which you can use, check the target you are overriding in the |
||||
nbproject/build-impl.xml file. |
||||
|
||||
--> |
||||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0 |
||||
X-COMMENT: Main-Class will be added automatically by build |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=9bff76db |
||||
build.xml.script.CRC32=def1c8af |
||||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48 |
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
nbproject/build-impl.xml.data.CRC32=9bff76db |
||||
nbproject/build-impl.xml.script.CRC32=4dede8da |
||||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
compile.on.save=true |
||||
user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
annotation.processing.enabled=true |
||||
annotation.processing.enabled.in.editor=false |
||||
annotation.processing.processor.options= |
||||
annotation.processing.processors.list= |
||||
annotation.processing.run.all.processors=true |
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
||||
build.classes.dir=${build.dir}/classes |
||||
build.classes.excludes=**/*.java,**/*.form |
||||
# This directory is removed when the project is cleaned: |
||||
build.dir=build |
||||
build.generated.dir=${build.dir}/generated |
||||
build.generated.sources.dir=${build.dir}/generated-sources |
||||
# Only compile against the classpath explicitly listed here: |
||||
build.sysclasspath=ignore |
||||
build.test.classes.dir=${build.dir}/test/classes |
||||
build.test.results.dir=${build.dir}/test/results |
||||
# Uncomment to specify the preferred debugger connection transport: |
||||
#debug.transport=dt_socket |
||||
debug.classpath=\ |
||||
${run.classpath} |
||||
debug.test.classpath=\ |
||||
${run.test.classpath} |
||||
# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar |
||||
dist.archive.excludes= |
||||
# This directory is removed when the project is cleaned: |
||||
dist.dir=dist |
||||
dist.jar=${dist.dir}/GazStation2.jar |
||||
dist.javadoc.dir=${dist.dir}/javadoc |
||||
excludes= |
||||
includes=** |
||||
jar.compress=false |
||||
javac.classpath= |
||||
# Space-separated list of extra javac options |
||||
javac.compilerargs= |
||||
javac.deprecation=false |
||||
javac.external.vm=true |
||||
javac.processorpath=\ |
||||
${javac.classpath} |
||||
javac.source=1.8 |
||||
javac.target=1.8 |
||||
javac.test.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
javac.test.processorpath=\ |
||||
${javac.test.classpath} |
||||
javadoc.additionalparam= |
||||
javadoc.author=false |
||||
javadoc.encoding=${source.encoding} |
||||
javadoc.noindex=false |
||||
javadoc.nonavbar=false |
||||
javadoc.notree=false |
||||
javadoc.private=false |
||||
javadoc.splitindex=true |
||||
javadoc.use=true |
||||
javadoc.version=false |
||||
javadoc.windowtitle= |
||||
main.class=gazstation2.MainClass |
||||
manifest.file=manifest.mf |
||||
meta.inf.dir=${src.dir}/META-INF |
||||
mkdist.disabled=false |
||||
platform.active=default_platform |
||||
run.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
# Space-separated list of JVM arguments used when running the project. |
||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. |
||||
# To set system properties for unit tests define test-sys-prop.name=value: |
||||
run.jvmargs= |
||||
run.test.classpath=\ |
||||
${javac.test.classpath}:\ |
||||
${build.test.classes.dir} |
||||
source.encoding=UTF-8 |
||||
src.dir=src |
||||
test.src.dir=test |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.java.j2seproject</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> |
||||
<name>GazStation2</name> |
||||
<source-roots> |
||||
<root id="src.dir"/> |
||||
</source-roots> |
||||
<test-roots> |
||||
<root id="test.src.dir"/> |
||||
</test-roots> |
||||
</data> |
||||
</configuration> |
||||
</project> |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation2; |
||||
|
||||
import java.util.Random; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class Car extends Thread{ |
||||
public int tank; |
||||
private int max = 40; |
||||
public String name; |
||||
|
||||
@Override |
||||
public void run() { |
||||
for(int i=0 ; i<20 ; i++){ |
||||
fuel(); |
||||
try {Thread.sleep(1000);} catch (InterruptedException ex) {} |
||||
int fuel = new Random().nextInt(40); |
||||
tank -= fuel; |
||||
System.out.println(name + ": израсходовал " + fuel + " л. Объем топлива: " + tank); |
||||
} |
||||
} |
||||
|
||||
public Car(String name) { |
||||
this.name = name; |
||||
this.tank = new Random().nextInt(max-20); |
||||
} |
||||
|
||||
public void fuel(){ |
||||
int fuel = max - tank; |
||||
while(!GazStation.getState().column1.getFuel(this, fuel)){ |
||||
try {Thread.sleep(2000);} catch (InterruptedException ex) {} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation2; |
||||
|
||||
import java.util.Random; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class FilingColumn { |
||||
|
||||
private int bigTank; |
||||
private volatile boolean isOpen; |
||||
|
||||
public FilingColumn (){ |
||||
bigTank = new Random().nextInt(500); |
||||
isOpen = true; |
||||
} |
||||
|
||||
public int getBigTank() { |
||||
return bigTank; |
||||
} |
||||
|
||||
public synchronized boolean getFuel(Car car, int fuel) { |
||||
if(isOpen){ |
||||
if(bigTank<fuel){ |
||||
System.out.println(car.name + ": не достаточно топлива. Ожидает."); |
||||
GazStation.getState().callGazProducer(this); |
||||
isOpen = false; |
||||
}else{ |
||||
bigTank -= fuel; |
||||
car.tank += fuel; |
||||
System.out.println("--------------------------" + car.name + ": заправил " + fuel + " л. Объем топлива: " + car.tank); |
||||
} |
||||
} |
||||
return isOpen; |
||||
} |
||||
|
||||
public void addFuel(int fuel){ |
||||
bigTank += fuel; |
||||
isOpen = true; |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation2; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class GazProducer extends Thread{ |
||||
private FilingColumn column; |
||||
|
||||
public GazProducer(FilingColumn column){ |
||||
this.column = column; |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
System.out.println("Бензовоз выехал"); |
||||
call(); |
||||
} |
||||
|
||||
void call() { |
||||
int fuel = (new Random().nextInt(4)+1)*100; |
||||
column.addFuel(fuel); |
||||
System.out.println("Бензовоз залил " + fuel + " л., Остаток = " + column.getBigTank()); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation2; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
class GazStation { |
||||
public FilingColumn column1 = new FilingColumn(); |
||||
private static GazStation station = new GazStation(); |
||||
|
||||
|
||||
private GazStation(){} |
||||
|
||||
public static GazStation getState(){ |
||||
return station; |
||||
} |
||||
|
||||
public void callGazProducer(FilingColumn column){ |
||||
GazProducer gazProducer = new GazProducer(column); |
||||
System.out.println("Вызван бензовоз"); |
||||
gazProducer.start(); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package gazstation2; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MainClass { |
||||
|
||||
/** |
||||
* @param args the command line arguments |
||||
*/ |
||||
public static void main(String[] args) { |
||||
Car[] cars = new Car[10]; |
||||
for(int i =0 ; i<10 ; i++) { |
||||
cars[i] = new Car("Car№" + i); |
||||
} |
||||
for(Car car : cars) car.start(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- You may freely edit this file. See commented blocks below for --> |
||||
<!-- some examples of how to customize the build. --> |
||||
<!-- (If you delete it and reopen the project it will be recreated.) --> |
||||
<!-- By default, only the Clean and Build commands use this build script. --> |
||||
<!-- Commands such as Run, Debug, and Test only use this build script if --> |
||||
<!-- the Compile on Save feature is turned off for the project. --> |
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> |
||||
<!-- in the project's Project Properties dialog box.--> |
||||
<project name="MultithreadingExample" default="default" basedir="."> |
||||
<description>Builds, tests, and runs the project MultithreadingExample.</description> |
||||
<import file="nbproject/build-impl.xml"/> |
||||
<!-- |
||||
|
||||
There exist several targets which are by default empty and which can be |
||||
used for execution of your tasks. These targets are usually executed |
||||
before and after some main targets. They are: |
||||
|
||||
-pre-init: called before initialization of project properties |
||||
-post-init: called after initialization of project properties |
||||
-pre-compile: called before javac compilation |
||||
-post-compile: called after javac compilation |
||||
-pre-compile-single: called before javac compilation of single file |
||||
-post-compile-single: called after javac compilation of single file |
||||
-pre-compile-test: called before javac compilation of JUnit tests |
||||
-post-compile-test: called after javac compilation of JUnit tests |
||||
-pre-compile-test-single: called before javac compilation of single JUnit test |
||||
-post-compile-test-single: called after javac compilation of single JUunit test |
||||
-pre-jar: called before JAR building |
||||
-post-jar: called after JAR building |
||||
-post-clean: called after cleaning build products |
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.) |
||||
|
||||
Example of inserting an obfuscator after compilation could look like this: |
||||
|
||||
<target name="-post-compile"> |
||||
<obfuscate> |
||||
<fileset dir="${build.classes.dir}"/> |
||||
</obfuscate> |
||||
</target> |
||||
|
||||
For list of available properties check the imported |
||||
nbproject/build-impl.xml file. |
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets. |
||||
The targets of interest are: |
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation |
||||
-init-macrodef-junit: defines macro for junit execution |
||||
-init-macrodef-debug: defines macro for class debugging |
||||
-init-macrodef-java: defines macro for class execution |
||||
-do-jar: JAR building |
||||
run: execution of project |
||||
-javadoc-build: Javadoc generation |
||||
test-report: JUnit report generation |
||||
|
||||
An example of overriding the target for project execution could look like this: |
||||
|
||||
<target name="run" depends="MultithreadingExample-impl.jar"> |
||||
<exec dir="bin" executable="launcher.exe"> |
||||
<arg file="${dist.jar}"/> |
||||
</exec> |
||||
</target> |
||||
|
||||
Notice that the overridden target depends on the jar target and not only on |
||||
the compile target as the regular run target does. Again, for a list of available |
||||
properties which you can use, check the target you are overriding in the |
||||
nbproject/build-impl.xml file. |
||||
|
||||
--> |
||||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0 |
||||
X-COMMENT: Main-Class will be added automatically by build |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=87dec22c |
||||
build.xml.script.CRC32=3cf2961a |
||||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48 |
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
nbproject/build-impl.xml.data.CRC32=87dec22c |
||||
nbproject/build-impl.xml.script.CRC32=5ad5c371 |
||||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
compile.on.save=true |
||||
user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> |
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> |
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> |
||||
<group> |
||||
<file>file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/MultithreadingExample/src/multithreadingexample/BankOperation.java</file> |
||||
</group> |
||||
</open-files> |
||||
</project-private> |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
annotation.processing.enabled=true |
||||
annotation.processing.enabled.in.editor=false |
||||
annotation.processing.processor.options= |
||||
annotation.processing.processors.list= |
||||
annotation.processing.run.all.processors=true |
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
||||
build.classes.dir=${build.dir}/classes |
||||
build.classes.excludes=**/*.java,**/*.form |
||||
# This directory is removed when the project is cleaned: |
||||
build.dir=build |
||||
build.generated.dir=${build.dir}/generated |
||||
build.generated.sources.dir=${build.dir}/generated-sources |
||||
# Only compile against the classpath explicitly listed here: |
||||
build.sysclasspath=ignore |
||||
build.test.classes.dir=${build.dir}/test/classes |
||||
build.test.results.dir=${build.dir}/test/results |
||||
# Uncomment to specify the preferred debugger connection transport: |
||||
#debug.transport=dt_socket |
||||
debug.classpath=\ |
||||
${run.classpath} |
||||
debug.test.classpath=\ |
||||
${run.test.classpath} |
||||
# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar |
||||
dist.archive.excludes= |
||||
# This directory is removed when the project is cleaned: |
||||
dist.dir=dist |
||||
dist.jar=${dist.dir}/MultithreadingExample.jar |
||||
dist.javadoc.dir=${dist.dir}/javadoc |
||||
excludes= |
||||
includes=** |
||||
jar.compress=false |
||||
javac.classpath= |
||||
# Space-separated list of extra javac options |
||||
javac.compilerargs= |
||||
javac.deprecation=false |
||||
javac.external.vm=true |
||||
javac.processorpath=\ |
||||
${javac.classpath} |
||||
javac.source=1.8 |
||||
javac.target=1.8 |
||||
javac.test.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
javac.test.processorpath=\ |
||||
${javac.test.classpath} |
||||
javadoc.additionalparam= |
||||
javadoc.author=false |
||||
javadoc.encoding=${source.encoding} |
||||
javadoc.noindex=false |
||||
javadoc.nonavbar=false |
||||
javadoc.notree=false |
||||
javadoc.private=false |
||||
javadoc.splitindex=true |
||||
javadoc.use=true |
||||
javadoc.version=false |
||||
javadoc.windowtitle= |
||||
main.class=multithreadingexample.MainClass |
||||
manifest.file=manifest.mf |
||||
meta.inf.dir=${src.dir}/META-INF |
||||
mkdist.disabled=false |
||||
platform.active=default_platform |
||||
run.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
# Space-separated list of JVM arguments used when running the project. |
||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. |
||||
# To set system properties for unit tests define test-sys-prop.name=value: |
||||
run.jvmargs= |
||||
run.test.classpath=\ |
||||
${javac.test.classpath}:\ |
||||
${build.test.classes.dir} |
||||
source.encoding=UTF-8 |
||||
src.dir=src |
||||
test.src.dir=test |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.java.j2seproject</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> |
||||
<name>MultithreadingExample</name> |
||||
<source-roots> |
||||
<root id="src.dir"/> |
||||
</source-roots> |
||||
<test-roots> |
||||
<root id="test.src.dir"/> |
||||
</test-roots> |
||||
</data> |
||||
</configuration> |
||||
</project> |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedHashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class Bank { |
||||
public static List<BankAccount> accounts = new ArrayList<>(); |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample; |
||||
|
||||
import java.util.Random; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class BankAccount { |
||||
private int number; |
||||
private int fund; |
||||
|
||||
public BankAccount(int fund) { |
||||
this.number = new Random().nextInt(1000000); |
||||
this.fund = fund; |
||||
} |
||||
|
||||
public int getFund() { |
||||
return fund; |
||||
} |
||||
|
||||
public int fundUp(int summ){ |
||||
int fund = this.fund; |
||||
try {Thread.sleep(1000);} catch (InterruptedException ex) {} |
||||
fund += summ; |
||||
this.fund = fund; |
||||
return this.fund; |
||||
} |
||||
|
||||
public int fundDown(int summ){ |
||||
int fund = this.fund; |
||||
try {Thread.sleep(1000);} catch (InterruptedException ex) {} |
||||
fund -= summ; |
||||
this.fund = fund; |
||||
return this.fund; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample; |
||||
|
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class BankOperation implements Runnable{ |
||||
|
||||
@Override |
||||
public void run() { |
||||
BankAccount account = Bank.accounts.get(0); |
||||
|
||||
synchronized (account){ |
||||
String line = "Состояние до: " + account.getFund() + "руб., добавляем 10000 и получаем: " + account.fundUp(10000); |
||||
System.out.println(line); |
||||
} |
||||
|
||||
synchronized (account){ |
||||
String line = "Состояние до: " + account.getFund() + "руб., убавляем на 10000 и получаем: " + account.fundDown(10000); |
||||
System.out.println(line); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MainClass { |
||||
|
||||
/** |
||||
* @param args the command line arguments |
||||
*/ |
||||
public static void main(String[] args) { |
||||
System.out.println("Main thread is started"); |
||||
|
||||
Bank.accounts.add(new BankAccount(10000)); |
||||
|
||||
Thread thread1 = new Thread(new BankOperation()); |
||||
Thread thread2 = new Thread(new BankOperation()); |
||||
Thread thread3 = new Thread(new BankOperation()); |
||||
Thread thread4 = new Thread(new BankOperation()); |
||||
Thread thread5 = new Thread(new BankOperation()); |
||||
Thread thread6 = new Thread(new BankOperation()); |
||||
thread1.start(); |
||||
thread2.start(); |
||||
thread3.start(); |
||||
thread4.start(); |
||||
thread5.start(); |
||||
thread6.start(); |
||||
|
||||
System.out.println("Mian thread is stoped"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample; |
||||
|
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MyThread extends Thread{ |
||||
|
||||
@Override |
||||
public void run() { |
||||
//Thread.sleep(5000);
|
||||
System.out.println("Привет из параллельного потака 1"); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- You may freely edit this file. See commented blocks below for --> |
||||
<!-- some examples of how to customize the build. --> |
||||
<!-- (If you delete it and reopen the project it will be recreated.) --> |
||||
<!-- By default, only the Clean and Build commands use this build script. --> |
||||
<!-- Commands such as Run, Debug, and Test only use this build script if --> |
||||
<!-- the Compile on Save feature is turned off for the project. --> |
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> |
||||
<!-- in the project's Project Properties dialog box.--> |
||||
<project name="MultithreadingExample_2" default="default" basedir="."> |
||||
<description>Builds, tests, and runs the project MultithreadingExample_2.</description> |
||||
<import file="nbproject/build-impl.xml"/> |
||||
<!-- |
||||
|
||||
There exist several targets which are by default empty and which can be |
||||
used for execution of your tasks. These targets are usually executed |
||||
before and after some main targets. They are: |
||||
|
||||
-pre-init: called before initialization of project properties |
||||
-post-init: called after initialization of project properties |
||||
-pre-compile: called before javac compilation |
||||
-post-compile: called after javac compilation |
||||
-pre-compile-single: called before javac compilation of single file |
||||
-post-compile-single: called after javac compilation of single file |
||||
-pre-compile-test: called before javac compilation of JUnit tests |
||||
-post-compile-test: called after javac compilation of JUnit tests |
||||
-pre-compile-test-single: called before javac compilation of single JUnit test |
||||
-post-compile-test-single: called after javac compilation of single JUunit test |
||||
-pre-jar: called before JAR building |
||||
-post-jar: called after JAR building |
||||
-post-clean: called after cleaning build products |
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.) |
||||
|
||||
Example of inserting an obfuscator after compilation could look like this: |
||||
|
||||
<target name="-post-compile"> |
||||
<obfuscate> |
||||
<fileset dir="${build.classes.dir}"/> |
||||
</obfuscate> |
||||
</target> |
||||
|
||||
For list of available properties check the imported |
||||
nbproject/build-impl.xml file. |
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets. |
||||
The targets of interest are: |
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation |
||||
-init-macrodef-junit: defines macro for junit execution |
||||
-init-macrodef-debug: defines macro for class debugging |
||||
-init-macrodef-java: defines macro for class execution |
||||
-do-jar: JAR building |
||||
run: execution of project |
||||
-javadoc-build: Javadoc generation |
||||
test-report: JUnit report generation |
||||
|
||||
An example of overriding the target for project execution could look like this: |
||||
|
||||
<target name="run" depends="MultithreadingExample_2-impl.jar"> |
||||
<exec dir="bin" executable="launcher.exe"> |
||||
<arg file="${dist.jar}"/> |
||||
</exec> |
||||
</target> |
||||
|
||||
Notice that the overridden target depends on the jar target and not only on |
||||
the compile target as the regular run target does. Again, for a list of available |
||||
properties which you can use, check the target you are overriding in the |
||||
nbproject/build-impl.xml file. |
||||
|
||||
--> |
||||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0 |
||||
X-COMMENT: Main-Class will be added automatically by build |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=33ff94e6 |
||||
build.xml.script.CRC32=c811e3e8 |
||||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48 |
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
nbproject/build-impl.xml.data.CRC32=33ff94e6 |
||||
nbproject/build-impl.xml.script.CRC32=01054350 |
||||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
compile.on.save=true |
||||
user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
annotation.processing.enabled=true |
||||
annotation.processing.enabled.in.editor=false |
||||
annotation.processing.processor.options= |
||||
annotation.processing.processors.list= |
||||
annotation.processing.run.all.processors=true |
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
||||
build.classes.dir=${build.dir}/classes |
||||
build.classes.excludes=**/*.java,**/*.form |
||||
# This directory is removed when the project is cleaned: |
||||
build.dir=build |
||||
build.generated.dir=${build.dir}/generated |
||||
build.generated.sources.dir=${build.dir}/generated-sources |
||||
# Only compile against the classpath explicitly listed here: |
||||
build.sysclasspath=ignore |
||||
build.test.classes.dir=${build.dir}/test/classes |
||||
build.test.results.dir=${build.dir}/test/results |
||||
# Uncomment to specify the preferred debugger connection transport: |
||||
#debug.transport=dt_socket |
||||
debug.classpath=\ |
||||
${run.classpath} |
||||
debug.test.classpath=\ |
||||
${run.test.classpath} |
||||
# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar |
||||
dist.archive.excludes= |
||||
# This directory is removed when the project is cleaned: |
||||
dist.dir=dist |
||||
dist.jar=${dist.dir}/MultithreadingExample_2.jar |
||||
dist.javadoc.dir=${dist.dir}/javadoc |
||||
excludes= |
||||
includes=** |
||||
jar.compress=false |
||||
javac.classpath= |
||||
# Space-separated list of extra javac options |
||||
javac.compilerargs= |
||||
javac.deprecation=false |
||||
javac.external.vm=true |
||||
javac.processorpath=\ |
||||
${javac.classpath} |
||||
javac.source=1.8 |
||||
javac.target=1.8 |
||||
javac.test.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
javac.test.processorpath=\ |
||||
${javac.test.classpath} |
||||
javadoc.additionalparam= |
||||
javadoc.author=false |
||||
javadoc.encoding=${source.encoding} |
||||
javadoc.noindex=false |
||||
javadoc.nonavbar=false |
||||
javadoc.notree=false |
||||
javadoc.private=false |
||||
javadoc.splitindex=true |
||||
javadoc.use=true |
||||
javadoc.version=false |
||||
javadoc.windowtitle= |
||||
main.class=multithreadingexample_2.MultithreadingExample_2 |
||||
manifest.file=manifest.mf |
||||
meta.inf.dir=${src.dir}/META-INF |
||||
mkdist.disabled=false |
||||
platform.active=default_platform |
||||
run.classpath=\ |
||||
${javac.classpath}:\ |
||||
${build.classes.dir} |
||||
# Space-separated list of JVM arguments used when running the project. |
||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. |
||||
# To set system properties for unit tests define test-sys-prop.name=value: |
||||
run.jvmargs= |
||||
run.test.classpath=\ |
||||
${javac.test.classpath}:\ |
||||
${build.test.classes.dir} |
||||
source.encoding=UTF-8 |
||||
src.dir=src |
||||
test.src.dir=test |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.java.j2seproject</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> |
||||
<name>MultithreadingExample_2</name> |
||||
<source-roots> |
||||
<root id="src.dir"/> |
||||
</source-roots> |
||||
<test-roots> |
||||
<root id="test.src.dir"/> |
||||
</test-roots> |
||||
</data> |
||||
</configuration> |
||||
</project> |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class Bank { |
||||
public static List<BankAccount> accounts = new ArrayList<>(); |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class BankAccount { |
||||
private int number; |
||||
private int fund; |
||||
|
||||
public BankAccount(int fund) { |
||||
this.number = new Random().nextInt(1000000); |
||||
this.fund = fund; |
||||
} |
||||
|
||||
public int getFund() { |
||||
return fund; |
||||
} |
||||
|
||||
public synchronized int fundUp(int summ){ |
||||
int fund = this.fund; |
||||
//try {Thread.sleep(10);} catch (InterruptedException ex) {}
|
||||
fund += summ; |
||||
this.fund = fund; |
||||
return this.fund; |
||||
} |
||||
|
||||
public synchronized int fundDown(int summ){ |
||||
int fund = this.fund; |
||||
//try {Thread.sleep(10);} catch (InterruptedException ex) {}
|
||||
fund -= summ; |
||||
this.fund = fund; |
||||
return this.fund; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class BankOperation implements Runnable{ |
||||
|
||||
public boolean isPlus = true; |
||||
|
||||
@Override |
||||
public void run() { |
||||
BankAccount account = Bank.accounts.get(0); |
||||
|
||||
synchronized (account){ |
||||
if(isPlus){ |
||||
String line1 = "Состояние до: " + account.getFund() + "руб., добавляем 10000 и получаем: " + account.fundUp(10000); |
||||
System.out.println(line1); |
||||
}else{ |
||||
String line2 = "Состояние до: " + account.getFund() + "руб., убавляем на 10000 и получаем: " + account.fundDown(10000); |
||||
System.out.println(line2); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MultithreadingExample_2 { |
||||
|
||||
/** |
||||
* @param args the command line arguments |
||||
*/ |
||||
public static void main(String[] args) { |
||||
System.out.println("Main thread start"); |
||||
// MyThread1 thread1 = new MyThread1();
|
||||
// Thread thread = new Thread(thread1);
|
||||
// thread.start();
|
||||
//
|
||||
// MyThread2 thread2 = new MyThread2();
|
||||
// thread2.start();
|
||||
|
||||
|
||||
Bank.accounts.add(new BankAccount(10000)); |
||||
BankOperation operation1 = new BankOperation(); |
||||
operation1.isPlus = false; |
||||
BankOperation operation2 = new BankOperation(); |
||||
BankOperation operation3 = new BankOperation(); |
||||
operation3.isPlus = false; |
||||
BankOperation operation4 = new BankOperation(); |
||||
BankOperation operation5 = new BankOperation(); |
||||
operation5.isPlus = false; |
||||
BankOperation operation6 = new BankOperation(); |
||||
for(int i=0 ; i<50 ; i++){ |
||||
new Thread(operation1).start(); |
||||
new Thread(operation2).start(); |
||||
new Thread(operation3).start(); |
||||
new Thread(operation4).start(); |
||||
new Thread(operation5).start(); |
||||
new Thread(operation6).start(); |
||||
} |
||||
|
||||
System.out.println("Main thread finish"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MyThread1 implements Runnable{ |
||||
|
||||
@Override |
||||
public void run() { |
||||
try { |
||||
Thread.sleep(500); |
||||
System.out.println("Thread1 start"); |
||||
} catch (InterruptedException ex) { |
||||
Logger.getLogger(MyThread1.class.getName()).log(Level.SEVERE, null, ex); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package multithreadingexample_2; |
||||
|
||||
/** |
||||
* |
||||
* @author denis |
||||
*/ |
||||
public class MyThread2 extends Thread{ |
||||
|
||||
@Override |
||||
public void run() { |
||||
System.out.println("Thread2 start"); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue