diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..883ea48
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.idea/
+target/
+/*.iml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index b38c85c..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-HW
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index cdc4be7..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 6360958..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index e19c5f2..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 5c52d0b..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,301 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1455284315959
-
- 1455284315959
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JavaHW.iml b/JavaHW.iml
deleted file mode 100644
index 73f608b..0000000
--- a/JavaHW.iml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 91c9624..31f50f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,5 +8,12 @@
hw
1.0-SNAPSHOT
+
+
+ junit
+ junit
+ 4.12
+
+
\ No newline at end of file
diff --git a/src/main/java/Lazy.java b/src/main/java/Lazy.java
new file mode 100644
index 0000000..ca03b25
--- /dev/null
+++ b/src/main/java/Lazy.java
@@ -0,0 +1,7 @@
+/**
+ * Created by urijkravcenko on 12/02/16.
+ */
+
+public interface Lazy {
+ T get();
+}
diff --git a/src/main/java/LazyFactory.java b/src/main/java/LazyFactory.java
new file mode 100644
index 0000000..c039aac
--- /dev/null
+++ b/src/main/java/LazyFactory.java
@@ -0,0 +1,80 @@
+import java.util.concurrent.atomic.AtomicMarkableReference;
+import java.util.function.Supplier;
+
+/**
+ * Created by urijkravcenko on 12/02/16.
+ */
+
+public class LazyFactory {
+
+ abstract private static class MyLazy implements Lazy {
+ boolean got = false;
+ Object result = null;
+
+ MyLazy(Supplier supplier) {
+ result = supplier;
+ }
+ }
+
+ public static Lazy createLazy1(Supplier supplier) {
+
+ return new MyLazy(supplier) {
+
+ public T get() {
+ if (!got) {
+ got = true;
+ result = ((Supplier) result).get();
+ }
+ return (T) result;
+ }
+
+ };
+ }
+
+ public static Lazy createLazy2(Supplier supplier) {
+
+ return new MyLazy(supplier) {
+ public T get() {
+ if (!got) {
+ synchronized (this) {
+ if (!got) {
+ result = ((Supplier) result).get();
+ got = true;
+ }
+ }
+ }
+ return (T) result;
+ }
+
+ };
+ }
+
+ abstract private static class MyOtherLazy implements Lazy {
+ AtomicMarkableReference