nalilito talaga ako rito haha. lets say i have this class
SomeClass.java
Java:
public class SomeClass {
public boolean looping = true;
public void loop() {
while (looping) {
// some code
}
}
}
and my Main.java
Java:
public class Main {
SomeClass someClass;
public static void main(String args[]) {
someClass = new SomeClass();
new Thread() {
@Override
public void run() {
someClass.loop();
}
}.start();
}
on what thread i am blocking? sa bagong thread o sa main?
sorry , i mean tungkol po 'to sa thread, kung saan magkakaroon ng effect yung loop, kasi ininstantiate ko siya sa Main , then gumawa ng new thread sa main saka tinawag yung loop method sa loob ng SomeClass, dito ako nalilito kung anong thread ang blocked, both threads, main thread or yung new thread?
There is no blocked thread here. Main thread is running while another thread is running/executing the loop from your SomeClass Class. This is observable when you simulate threads in Android studio where threads are beneficial when your program has heavy task on background without interfering the Main thread that's handling the main processes and UI tasks.
There is no blocked thread here. Main thread is running while another thread is running/executing the loop from your SomeClass Class. This is observable when you simulate threads in Android studio where threads are beneficial when your program has heavy task on background without interfering the Main thread that's handling the main processes and UI tasks.
thanks aa1012 mali pala question ko pero nasagot mo yung "main thread-new thread" problem ko. api specific pala problem ko sa MediaPlayer library , dapat pala ayun sinabi ko una pa lang haha.
medyo tapos na kaso messy code base ko haha, 8080 emulation , specifically space invaders, nagpalit na ko ng library ko from MediaPlayer to SoundPool , di ko makuha async niya haha , ang hirap na kasi imaintain pag lumalaki
medyo tapos na kaso messy code base ko haha, 8080 emulation , specifically space invaders, nagpalit na ko ng library ko from MediaPlayer to SoundPool , di ko makuha async niya haha , ang hirap na kasi imaintain pag lumalaki
Android based paps? ganda ng project mo. That's fine kung mejo messy, ako nga din bago lang sa Android dev e. yung gawa kong messaging app with Bluetooth based peer messaging ang messy ng codes kahit gumamit ako ng 3 tier based classes, abstract at interfaces. Mahirap talaga pag di ka familiar sa isang sdk, library at api, mangangapa ka pero kaya naman imanipulate at paglaruan. masayang pag aralan.
Android based paps? ganda ng project mo. That's fine kung mejo messy, ako nga din bago lang sa Android dev e. yung gawa kong messaging app with Bluetooth based peer messaging ang messy ng codes kahit gumamit ako ng 3 tier based classes, abstract at interfaces. Mahirap talaga pag di ka familiar sa isang sdk, library at api, mangangapa ka pero kaya naman imanipulate at paglaruan. masayang pag aralan.