-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ndroi
committed
Jul 24, 2020
1 parent
966b593
commit ab27bd3
Showing
5 changed files
with
67 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
Easy163/app/src/main/java/org/ndroi/easy163/hooks/SongPlayHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 41 additions & 29 deletions
70
.../easy163/hooks/utils/ConcurrencyTask.java → .../ndroi/easy163/utils/ConcurrencyTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
package org.ndroi.easy163.hooks.utils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ConcurrencyTask | ||
{ | ||
private List<Thread> threads = new ArrayList<>(); | ||
|
||
public void addTask(Thread thread) | ||
{ | ||
threads.add(thread); | ||
thread.start(); | ||
} | ||
|
||
public void waitAll() | ||
{ | ||
try | ||
{ | ||
for (Thread thread : threads) | ||
{ | ||
thread.join(); | ||
} | ||
} catch (InterruptedException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
package org.ndroi.easy163.utils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ConcurrencyTask | ||
{ | ||
private List<Thread> threads = new ArrayList<>(); | ||
|
||
public void addTask(Thread thread) | ||
{ | ||
threads.add(thread); | ||
thread.start(); | ||
} | ||
|
||
public boolean isAllFinished() | ||
{ | ||
for (Thread thread : threads) | ||
{ | ||
if(thread.isAlive()) | ||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
public void waitAll() | ||
{ | ||
try | ||
{ | ||
for (Thread thread : threads) | ||
{ | ||
thread.join(); | ||
} | ||
} catch (InterruptedException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters