Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-concurrency-examples
Project
Project
Details
Activity
Releases
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
Gabriele Civitarese
java-concurrency-examples
Commits
9a158211
Commit
9a158211
authored
Apr 02, 2020
by
Gabriele Civitarese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all the code under src folder
parent
3616ae49
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
31 additions
and
3 deletions
+31
-3
Main.java
src/join/Main.java
+3
-0
MyThread.java
src/join/MyThread.java
+2
-0
Consumer.java
src/producerConsumer/Consumer.java
+2
-0
Main.java
src/producerConsumer/Main.java
+2
-0
Producer.java
src/producerConsumer/Producer.java
+2
-0
Queue.java
src/producerConsumer/Queue.java
+2
-0
Consumer.java
src/producerConsumerUnsynced/Consumer.java
+2
-0
Main.java
src/producerConsumerUnsynced/Main.java
+2
-0
Producer.java
src/producerConsumerUnsynced/Producer.java
+2
-0
Queue.java
src/producerConsumerUnsynced/Queue.java
+2
-0
Main.java
src/semaphore/Main.java
+2
-1
MyThread.java
src/semaphore/MyThread.java
+2
-0
Semaphore.java
src/semaphore/Semaphore.java
+2
-2
Main.java
src/semaphoreAPI/Main.java
+2
-0
MyThread.java
src/semaphoreAPI/MyThread.java
+2
-0
No files found.
esempioJ
oin/Main.java
→
src/j
oin/Main.java
View file @
9a158211
package
join
;
import
java.util.ArrayList
;
import
java.util.Random
;
...
...
@@ -22,6 +24,7 @@ public class Main {
for
(
Thread
t
:
threads
)
{
t
.
join
();
}
System
.
out
.
println
(
"...All thread finished!"
);
}
...
...
esempioJ
oin/MyThread.java
→
src/j
oin/MyThread.java
View file @
9a158211
package
join
;
import
java.util.Random
;
public
class
MyThread
extends
Thread
{
...
...
producerConsumer/Consumer.java
→
src/
producerConsumer/Consumer.java
View file @
9a158211
package
producerConsumer
;
public
class
Consumer
implements
Runnable
{
private
final
Queue
queue
;
...
...
producerConsumer/Main.java
→
src/
producerConsumer/Main.java
View file @
9a158211
package
producerConsumer
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
Queue
q
=
new
Queue
();
...
...
producerConsumer/Producer.java
→
src/
producerConsumer/Producer.java
View file @
9a158211
package
producerConsumer
;
public
class
Producer
implements
Runnable
{
private
final
String
id
;
...
...
producerConsumer/Queue.java
→
src/
producerConsumer/Queue.java
View file @
9a158211
package
producerConsumer
;
import
java.util.ArrayList
;
public
class
Queue
{
...
...
producerConsumerUnsynced/Consumer.java
→
src/
producerConsumerUnsynced/Consumer.java
View file @
9a158211
package
producerConsumerUnsynced
;
public
class
Consumer
implements
Runnable
{
private
final
Queue
queue
;
...
...
producerConsumerUnsynced/Main.java
→
src/
producerConsumerUnsynced/Main.java
View file @
9a158211
package
producerConsumerUnsynced
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
Queue
q
=
new
Queue
();
...
...
producerConsumerUnsynced/Producer.java
→
src/
producerConsumerUnsynced/Producer.java
View file @
9a158211
package
producerConsumerUnsynced
;
public
class
Producer
implements
Runnable
{
private
final
String
id
;
...
...
producerConsumerUnsynced/Queue.java
→
src/
producerConsumerUnsynced/Queue.java
View file @
9a158211
package
producerConsumerUnsynced
;
import
java.util.ArrayList
;
//Esempio di coda condivisa che non usa wait e notify
...
...
semaphore/Main.java
→
s
rc/s
emaphore/Main.java
View file @
9a158211
package
semaphore
;
import
java.util.ArrayList
;
import
java.util.Random
;
//Utilizzo di un semaforo "fatto a "
public
class
Main
{
public
static
void
main
(
String
arg
[])
throws
Exception
{
Random
r
=
new
Random
();
...
...
semaphore/MyThread.java
→
s
rc/s
emaphore/MyThread.java
View file @
9a158211
package
semaphore
;
import
java.util.Random
;
public
class
MyThread
extends
Thread
{
...
...
semaphore/Semaphore.java
→
s
rc/s
emaphore/Semaphore.java
View file @
9a158211
//Classe che implementa tramite wait e notify un Semaforo.
package
semaphore
;
//Classe che implementa tramite wait e notify un Semaforo.
//Se non vi ricordate cosa sia un semaforo, google is your best friend.
public
class
Semaphore
extends
Thread
{
public
class
Semaphore
{
private
int
maxNumber
;
//numero massimo di thread
private
int
threadsIn
;
//conteggio dei thread nell'area critica
...
...
semaphoreAPI/Main.java
→
s
rc/s
emaphoreAPI/Main.java
View file @
9a158211
package
semaphoreAPI
;
import
java.util.Random
;
import
java.util.Vector
;
import
java.util.concurrent.Semaphore
;
...
...
semaphoreAPI/MyThread.java
→
s
rc/s
emaphoreAPI/MyThread.java
View file @
9a158211
package
semaphoreAPI
;
import
java.util.Random
;
import
java.util.concurrent.Semaphore
;
...
...
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