Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
first_git
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
areej.mohammad
first_git
Commits
e55cdbf6
Commit
e55cdbf6
authored
Nov 04, 2025
by
areej.mohammad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
step 5
parent
55577373
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
VaultHackingRace.java
src/hackingrace/VaultHackingRace.java
+6
-6
No files found.
src/hackingrace/VaultHackingRace.java
View file @
e55cdbf6
...
@@ -2,18 +2,18 @@ package hackingrace;
...
@@ -2,18 +2,18 @@ package hackingrace;
public
class
VaultHackingRace
{
public
class
VaultHackingRace
{
public
static
void
main
(
String
[]
args
){
public
static
void
main
(
String
[]
args
){
// 1. Create a Vault with a random password
Vault
vault
=
new
Vault
();
Vault
vault
=
new
Vault
();
// 2. Instantiate the three threads
Thread
ascendingHacker
=
new
AscendingHackerThread
(
vault
);
Thread
ascendingHacker
=
new
AscendingHackerThread
(
vault
);
Thread
descendingHacker
=
new
DescendingHackerThread
(
vault
);
Thread
descendingHacker
=
new
DescendingHackerThread
(
vault
);
Thread
policeThread
=
new
PoliceThread
();
Thread
policeThread
=
new
PoliceThread
();
// 3. يستخدم أولوية Thread.MAX_PRIORITY لنياسب القراصنة [cite: 28, 45]
// 3. Set the priority of the hacker threads to maximum
ascendingHacker
.
setPriority
(
Thread
.
MAX_PRIORITY
);
ascendingHacker
.
setPriority
(
Thread
.
MAX_PRIORITY
);
descendingHacker
.
setPriority
(
Thread
.
MAX_PRIORITY
);
descendingHacker
.
setPriority
(
Thread
.
MAX_PRIORITY
);
// نيسب الشرطة يعمل بالأولوية الافتراضية (عادةً NORM_PRIORITY)
// 4. Start all three threads simultaneously
// 4. يُطلق النياسب الثلاثة في نفس الوقت [cite: 27]
policeThread
.
start
();
policeThread
.
start
();
ascendingHacker
.
start
();
ascendingHacker
.
start
();
descendingHacker
.
start
();
descendingHacker
.
start
();
...
@@ -21,8 +21,8 @@ public static void main(String[] args){
...
@@ -21,8 +21,8 @@ public static void main(String[] args){
System
.
out
.
println
(
"Two hackers are competing to find the password (0-9999)."
);
System
.
out
.
println
(
"Two hackers are competing to find the password (0-9999)."
);
System
.
out
.
println
(
"Police arrive in 10 seconds. Hackers have MAX_PRIORITY."
);
System
.
out
.
println
(
"Police arrive in 10 seconds. Hackers have MAX_PRIORITY."
);
System
.
out
.
println
(
"------------------------------------"
);
System
.
out
.
println
(
"------------------------------------"
);
// البرنامج ينتظر حتى يُنهي System.exi
t(0)
// البرنامج ينتظر حتى يُنهي System.exi
}
}
}
}
ls
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