Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_mszczonow_1
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
alx_mszczonow_1
Commits
79ed24f1
Commit
79ed24f1
authored
Jul 11, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usunięcie throws
parent
ec882af2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
6 deletions
+2
-6
Konto.java
src/main/java/p28_watki/b_synchro/v1_metody/Konto.java
+1
-1
WyplacanieZOczekiwaniem.java
...28_watki/b_synchro/v1_metody/WyplacanieZOczekiwaniem.java
+1
-5
No files found.
src/main/java/p28_watki/b_synchro/v1_metody/Konto.java
View file @
79ed24f1
...
@@ -48,7 +48,7 @@ class Konto {
...
@@ -48,7 +48,7 @@ class Konto {
saldo
-=
kwota
;
saldo
-=
kwota
;
}
}
public
synchronized
void
wyplataCzekaj
(
int
kwota
)
throws
BrakSrodkow
{
public
synchronized
void
wyplataCzekaj
(
int
kwota
)
{
if
(
kwota
<
0
)
{
if
(
kwota
<
0
)
{
throw
new
IllegalArgumentException
(
"Ujemna kwota "
+
kwota
+
" w wypłacie"
);
throw
new
IllegalArgumentException
(
"Ujemna kwota "
+
kwota
+
" w wypłacie"
);
}
}
...
...
src/main/java/p28_watki/b_synchro/v1_metody/WyplacanieZOczekiwaniem.java
View file @
79ed24f1
...
@@ -28,11 +28,7 @@ class WyplacanieZOczekiwaniem {
...
@@ -28,11 +28,7 @@ class WyplacanieZOczekiwaniem {
Thread
wyplacacz
=
new
Thread
(
new
Runnable
()
{
Thread
wyplacacz
=
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
while
(!
koniec
)
{
while
(!
koniec
)
{
try
{
konto
.
wyplataCzekaj
(
100
);
konto
.
wyplataCzekaj
(
100
);
}
catch
(
BrakSrodkow
e
)
{
System
.
err
.
println
(
"BRAK ŚRODKÓW"
);
}
System
.
out
.
println
(
"wypłacacz: wypłaciłem 100, saldo = "
+
konto
.
getSaldo
());
System
.
out
.
println
(
"wypłacacz: wypłaciłem 100, saldo = "
+
konto
.
getSaldo
());
try
{
try
{
Thread
.
sleep
(
200
);
Thread
.
sleep
(
200
);
...
...
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