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
5 years ago
by
Gabriele Civitarese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all the code under src folder
parent
3616ae49
Changes
15
Show 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!"
);
}
...
...
This diff is collapsed.
Click to expand it.
esempioJ
oin/MyThread.java
→
src/j
oin/MyThread.java
View file @
9a158211
package
join
;
import
java.util.Random
;
public
class
MyThread
extends
Thread
{
...
...
This diff is collapsed.
Click to expand it.
producerConsumer/Consumer.java
→
src/
producerConsumer/Consumer.java
View file @
9a158211
package
producerConsumer
;
public
class
Consumer
implements
Runnable
{
private
final
Queue
queue
;
...
...
This diff is collapsed.
Click to expand it.
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
();
...
...
This diff is collapsed.
Click to expand it.
producerConsumer/Producer.java
→
src/
producerConsumer/Producer.java
View file @
9a158211
package
producerConsumer
;
public
class
Producer
implements
Runnable
{
private
final
String
id
;
...
...
This diff is collapsed.
Click to expand it.
producerConsumer/Queue.java
→
src/
producerConsumer/Queue.java
View file @
9a158211
package
producerConsumer
;
import
java.util.ArrayList
;
public
class
Queue
{
...
...
This diff is collapsed.
Click to expand it.
producerConsumerUnsynced/Consumer.java
→
src/
producerConsumerUnsynced/Consumer.java
View file @
9a158211
package
producerConsumerUnsynced
;
public
class
Consumer
implements
Runnable
{
private
final
Queue
queue
;
...
...
This diff is collapsed.
Click to expand it.
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
();
...
...
This diff is collapsed.
Click to expand it.
producerConsumerUnsynced/Producer.java
→
src/
producerConsumerUnsynced/Producer.java
View file @
9a158211
package
producerConsumerUnsynced
;
public
class
Producer
implements
Runnable
{
private
final
String
id
;
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
();
...
...
This diff is collapsed.
Click to expand it.
semaphore/MyThread.java
→
s
rc/s
emaphore/MyThread.java
View file @
9a158211
package
semaphore
;
import
java.util.Random
;
public
class
MyThread
extends
Thread
{
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
;
...
...
This diff is collapsed.
Click to expand it.
semaphoreAPI/MyThread.java
→
s
rc/s
emaphoreAPI/MyThread.java
View file @
9a158211
package
semaphoreAPI
;
import
java.util.Random
;
import
java.util.concurrent.Semaphore
;
...
...
This diff is collapsed.
Click to expand it.
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