Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jvstd1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
jvstd1
Commits
95a3dfa0
Commit
95a3dfa0
authored
Oct 23, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Konto w wątkach - wypłacanie bez czekania
parent
0b9dea27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
Wyplacanie.java
src/main/java/p19_watki/konto/v0/Wyplacanie.java
+35
-0
Wyplacanie1.java
src/main/java/p19_watki/konto/v1/Wyplacanie1.java
+35
-0
No files found.
src/main/java/p19_watki/konto/v0/Wyplacanie.java
0 → 100644
View file @
95a3dfa0
package
p19_watki
.
konto
.
v0
;
public
class
Wyplacanie
{
public
static
void
main
(
String
[]
args
)
{
Konto
konto
=
new
Konto
(
1
,
"Ala"
,
15_000
);
System
.
out
.
println
(
"początek main: "
+
konto
);
Thread
wplacacz
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
Thread
.
sleep
(
10_000
);
konto
.
wplata
(
10_000
);
System
.
out
.
println
(
"Po wpłacie jest "
+
konto
.
getSaldo
());
}
}
catch
(
InterruptedException
e
)
{}
});
Thread
wyplacacz
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
try
{
Thread
.
sleep
(
500
);
konto
.
wyplata
(
700
);
System
.
out
.
println
(
"Po wypłacie jest "
+
konto
.
getSaldo
());
}
catch
(
BrakSrodkow
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
}
}
}
catch
(
InterruptedException
e
)
{}
});
wplacacz
.
start
();
wyplacacz
.
start
();
System
.
out
.
println
(
"wątki uruchomione"
);
}
}
src/main/java/p19_watki/konto/v1/Wyplacanie1.java
0 → 100644
View file @
95a3dfa0
package
p19_watki
.
konto
.
v1
;
public
class
Wyplacanie1
{
public
static
void
main
(
String
[]
args
)
{
Konto
konto
=
new
Konto
(
1
,
"Ala"
,
15_000
);
System
.
out
.
println
(
"początek main: "
+
konto
);
Thread
wplacacz
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
Thread
.
sleep
(
10_000
);
konto
.
wplata
(
10_000
);
System
.
out
.
println
(
"Po wpłacie jest "
+
konto
.
getSaldo
());
}
}
catch
(
InterruptedException
e
)
{}
});
Thread
wyplacacz
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
try
{
Thread
.
sleep
(
500
);
konto
.
wyplata
(
700
);
System
.
out
.
println
(
"Po wypłacie jest "
+
konto
.
getSaldo
());
}
catch
(
BrakSrodkow
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
}
}
}
catch
(
InterruptedException
e
)
{}
});
wplacacz
.
start
();
wyplacacz
.
start
();
System
.
out
.
println
(
"wątki uruchomione"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment