Konloch   10-02-2014, 07:18 AM
#1
Code:
package me.konloch.kontainer.api.threading; import java.util.ArrayList; /** * A simple thread manager class * * @author Konloch (http://konloch.me | http://the.bytecode.club) * * TODO: * Make addThread return an int for the thread id, then make a basic tracking system * ^ use some form of map to do this (hashmap?) * */ public class ThreadManager { private ArrayList<Thread> threadPool; /** * Create a new instance of the thread manager */ public ThreadManager() { threadPool = new ArrayList<Thread>(); } /** * Adds a thread to the thread pool * @param t the thread */ public void addThread(Thread t) { threadPool.add(t); } /** * Removes the thread object from the pool * @param t the cached thread object */ public void removeThread(Thread t) { threadPool.remove(t); } /** * Starts all non-active threads */ public void startThreads() { for(Thread t : threadPool) if(!t.isAlive()) t.start(); } /** * Attempts to halt all the active threads */ @SuppressWarnings("deprecation") public void stopThreads() { for(Thread t : threadPool) t.stop(); //< incase the stop function is overrided so they can handle an external stop. } /** * If threads are running it'll return true; * @return if any threads are running */ public boolean areThreadsRunning() { for(Thread t : threadPool) if(t.isAlive()) return true; return false; } }

Feel free to do what you want with it, read the TODO list for improvements.
Septron   03-01-2015, 01:18 PM
#2
This inspired me to write this...

https://gist.github.com/anonymous/1e8de4e6a5d112cc8815 Enjoy~
Konloch   03-01-2015, 02:25 PM
#3
(03-01-2015, 01:18 PM)Septron Wrote: This inspired me to write this...

https://gist.github.com/anonymous/1e8de4e6a5d112cc8815 Enjoy~

Awesome job!
  
Users browsing this thread: 1 Guest(s)
Konloch Software - Bytecode Viewer - Hack Log - Reverse Engineering Forum
Copyright © 2014-2026 The Bytecode Club. Powered By MyBB.
CC0 Unless Specified Otherwise.