Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java2b_20250412
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_java2b_20250412
Commits
a1de33df
Commit
a1de33df
authored
Apr 12, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Poprawki w trakcie omawiania wątków
parent
f6470812
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
15 deletions
+20
-15
Afrykarium3.java
...ava/watki/ilustracje_nie_do_uruchamiania/Afrykarium3.java
+4
-0
WyplacanieZOczekiwaniem.java
...onta/v2_synchronizacja_metod/WyplacanieZOczekiwaniem.java
+4
-3
Watki1.java
PC20-ObiektyIWatki/src/main/java/watki/podstawy/Watki1.java
+4
-4
Watki2_Join.java
...iektyIWatki/src/main/java/watki/podstawy/Watki2_Join.java
+4
-4
Watki3_Demon.java
...ektyIWatki/src/main/java/watki/podstawy/Watki3_Demon.java
+4
-4
No files found.
PC20-ObiektyIWatki/src/main/java/watki/ilustracje_nie_do_uruchamiania/Afrykarium3.java
View file @
a1de33df
...
...
@@ -19,4 +19,8 @@ public class Afrykarium3 {
public
void
zwiedzaj
ą
cyWychodzi
()
{
miejsca
.
release
();
// ++ akademicko: V
}
public
void
grupaWychodzi
(
int
ilu
)
{
miejsca
.
release
(
ilu
);
}
}
PC20-ObiektyIWatki/src/main/java/watki/konta/v2_synchronizacja_metod/WyplacanieZOczekiwaniem.java
View file @
a1de33df
...
...
@@ -28,12 +28,12 @@ class WyplacanieZOczekiwaniem {
Thread
wyplacacz
=
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
while
(!
koniec
)
{
konto
.
wyplataCzekaj
(
100
);
System
.
out
.
println
(
"wypłacacz: wypłaciłem 100, saldo = "
+
konto
.
getSaldo
());
try
{
Thread
.
sleep
(
200
);
}
catch
(
InterruptedException
e
)
{
}
konto
.
wyplataCzekaj
(
100
);
System
.
out
.
println
(
"wypłacacz: wypłaciłem 100, saldo = "
+
konto
.
getSaldo
());
}
}
});
...
...
@@ -49,7 +49,8 @@ class WyplacanieZOczekiwaniem {
}
koniec
=
true
;
wplacacz
.
interrupt
();
wyplacacz
.
interrupt
();
try
{
wplacacz
.
join
();
wyplacacz
.
join
();
...
...
PC20-ObiektyIWatki/src/main/java/watki/podstawy/Watki1.java
View file @
a1de33df
...
...
@@ -4,16 +4,16 @@ public class Watki1 {
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Początek main"
);
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
1
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
1
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
1
00
,
1
));
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
2
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
2
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
2
00
,
1
));
th1
.
start
();
th2
.
start
();
th3
.
start
();
System
.
out
.
println
(
"main: wątki uruchomione"
);
try
{
Thread
.
sleep
(
5
0
);
Thread
.
sleep
(
9
0
);
}
catch
(
InterruptedException
e
)
{
}
System
.
out
.
println
(
"main: poczekałem sobie"
);
...
...
PC20-ObiektyIWatki/src/main/java/watki/podstawy/Watki2_Join.java
View file @
a1de33df
...
...
@@ -4,9 +4,9 @@ public class Watki2_Join {
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Początek main"
);
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
1
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
1
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
1
00
,
1
));
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
2
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
2
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
2
00
,
1
));
System
.
out
.
println
(
"stan przed start: "
+
th1
.
getState
());
...
...
@@ -15,7 +15,7 @@ public class Watki2_Join {
th3
.
start
();
System
.
out
.
println
(
"main: wątki uruchomione, mój nr "
+
Thread
.
currentThread
().
getId
());
try
{
Thread
.
sleep
(
5
0
);
Thread
.
sleep
(
9
0
);
}
catch
(
InterruptedException
e
)
{
}
System
.
out
.
println
(
"main: Teraz będę czekał na wątki za pomocą join"
);
...
...
PC20-ObiektyIWatki/src/main/java/watki/podstawy/Watki3_Demon.java
View file @
a1de33df
...
...
@@ -4,9 +4,9 @@ public class Watki3_Demon {
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Początek main"
);
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
1
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
1
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
1
00
,
1
));
Thread
th1
=
new
Thread
(
new
WatekWypisujacy
(
"A"
,
2
00
,
1
));
Thread
th2
=
new
Thread
(
new
WatekWypisujacy
(
"B"
,
2
00
,
1
));
Thread
th3
=
new
Thread
(
new
WatekWypisujacy
(
"C"
,
2
00
,
1
));
th1
.
setDaemon
(
true
);
th2
.
setDaemon
(
true
);
...
...
@@ -22,7 +22,7 @@ public class Watki3_Demon {
System
.
out
.
println
(
"main: wątki uruchomione"
);
try
{
Thread
.
sleep
(
5
0
);
Thread
.
sleep
(
9
0
);
}
catch
(
InterruptedException
e
)
{
}
System
.
out
.
println
(
"main: poczekałem sobie"
);
...
...
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