[android-developers] Re: Problem With Thread !

2010-10-28 Thread Bob Kerns
Yes, but I wasn't making a general comment, but specifically addressing your statement that inner classes "aren't real" because the there's no real specific JVM support for them. It seems you were making a comment about the JVM in the guise of a comment about the language. Now that we've cleared t

[android-developers] Re: Problem With Thread !

2010-10-26 Thread Bob Kerns
I used the word "need" as in "require to function", as opposed to "have a use for". I'm not about to argue that the JVM couldn't support them better with more information. Even if I couldn't think of a reason, I would still bet on more information allowing for better support. Perhaps what you're r

[android-developers] Re: Problem With Thread !

2010-10-26 Thread DanH
The JVM certainly could make use of the knowledge. As it is, there are some significant security holes, and the JVM must have some "special" rules (loopholes) so that inner classes will work. And the scheme used is slower and much more cumbersome than would be an implementation where the JVM is i

[android-developers] Re: Problem With Thread !

2010-10-26 Thread MarcoCanali
Thanks a Lot , i'Ve Discover New World !! Now It Work ! On 23 Ott, 11:59, Kostya Vasilyev wrote: > Marco, > > If you're going to control periodic / scheduled events, then you don't > need a thread at all. > > Take a look at AlarmManager, and schedule an alarm at appropriate time. > AlarmManager w

[android-developers] Re: Problem With Thread !

2010-10-23 Thread Bob Kerns
Re your first paragraph: nicely put! That's the separation of concerns I was referring to. Re your second paragraph: I'd agree, except I can't detect any real convenience for the implementation. My point is that at the time it was defined, inheritance for the convenience of implementation was pret

[android-developers] Re: Problem With Thread !

2010-10-23 Thread Bob Kerns
That's because the JVM doesn't NEED any other knowledge. The JVM doesn't define the language -- the compiler does. The JVM is the environment the compiler targets, but with a different compiler, you get, say, Scheme or AspectJ instead of Java. Taking your argument to the logical conclusion, nothi

[android-developers] Re: Problem With Thread !

2010-10-23 Thread DanH
(The problem is that several of the "authoritative" examples of using postDelayed that you'll find on the net make this error, and lead many astray.) On Oct 23, 5:00 am, Kostya Vasilyev wrote: > 23.10.2010 4:04, Bob Kerns пишет:> Because you're left with two dead birds > instead of one? > > Or a

[android-developers] Re: Problem With Thread !

2010-10-23 Thread DanH
Of course, I can treat a String as a boolean. Any class can be abused by the ignorant. But that's all beside the point. Thread isn't going to change. The bizarre use of Thread as a Runnable, though (which appears to only occur in Android), though, should be "called out" wherever it's seen. Usin

[android-developers] Re: Problem With Thread !

2010-10-23 Thread DanH
You're still just running in the UI thread. You need to start another thread somehow (there are several ways, that others can enumerate better than I can). On Oct 23, 4:39 am, MarcoCanali wrote: > Ok i Implements Runnable for put the service in Waith() i call > Thread.sleep()  in run() method of

[android-developers] Re: Problem With Thread !

2010-10-23 Thread DanH
> Inner classes certainly exist Only as a fiction of javac. The JVM has no knowledge of them, other than the InnerClasses attribute that's really just for debugging and reflections. On Oct 22, 11:17 pm, Bob Kerns wrote: > There's always been Runnable, yes, but there hasn't always been the > cul

Re: [android-developers] Re: Problem With Thread !

2010-10-23 Thread Kostya Vasilyev
class MyThread extends Thread { . @Override public void run() { // put code here } } /// elsewhere mThread = new MyThread(); mThread.start(); <<<-- this forks the execution path -- Kostya 23.10.2010 14:00, MarcoCanali пишет: Yes Right ... How can resolve the probl

Re: [android-developers] Re: Problem With Thread !

2010-10-23 Thread Kostya Vasilyev
23.10.2010 4:04, Bob Kerns пишет: Because you're left with two dead birds instead of one? Or a ragout made out of two pigeons and marshmallows :) Perhaps pretty, but inedible. Runnable is an interface for packaging code into an object. There is nothing about threading inherent in Runnable.

[android-developers] Re: Problem With Thread !

2010-10-23 Thread MarcoCanali
Yes Right ... How can resolve the problem, and run the run() method without intact the UI thread !! Thanks a Lot On 22 Ott, 23:09, Kostya Vasilyev wrote: > Right, instead of starting a thread he posts its body as a runnable to the > UI thread, and sleep causes an ANR. > > Since he has a call to s

Re: [android-developers] Re: Problem With Thread !

2010-10-23 Thread Kostya Vasilyev
Marco, If you're going to control periodic / scheduled events, then you don't need a thread at all. Take a look at AlarmManager, and schedule an alarm at appropriate time. AlarmManager will wake up the phone (as needed) and fire off a PendingIntent, which you can receive with a BroadcastRece

[android-developers] Re: Problem With Thread !

2010-10-23 Thread MarcoCanali
Before i use the Runnable interface and call in run method the "Thread.sleep()" for put the service in wait for a moment, my service controlls the appointment for all time the device is on , but the problem is the same my UI don't respond to any command !! On 22 Ott, 22:41, Kostya Vasilyev wrote:

[android-developers] Re: Problem With Thread !

2010-10-23 Thread MarcoCanali
Ok i Implements Runnable for put the service in Waith() i call Thread.sleep() in run() method of class that Implements Runnable and The Problem is the Same ; The stone don't hit the two Bird On 22 Ott, 23:32, DanH wrote: > Thread implements Runnable mainly as a convenience.  When you want

[android-developers] Re: Problem With Thread !

2010-10-22 Thread Bob Kerns
There's always been Runnable, yes, but there hasn't always been the cultural emphasis on composition rather than derivation. In other words, I agree it was a mistake, but it was a mistake born of its time, and not one that would be as likely to be repeated today. Inner classes certainly exist -- t

[android-developers] Re: Problem With Thread !

2010-10-22 Thread DanH
But there's always been a Runnable, and it's no more difficult to subclass a Runnable than a Thread. Inner classes made it easier (if more obscure) to define your subclasses, but didn't change the basic nature of the beast. (In fact, in reality inner classes don't exist.) On Oct 22, 7:04 pm, Bob

[android-developers] Re: Problem With Thread !

2010-10-22 Thread Bob Kerns
Because you're left with two dead birds instead of one? A more serious answer would be that this stems from the early days of Java, and it was not so convenient to supply a Runnable, because there were no inner classes back then. A lack of experience with the language at that point left open the p

[android-developers] Re: Problem With Thread !

2010-10-22 Thread DanH
Thread implements Runnable mainly as a convenience. When you want to start a thread you need a Runnable to execute. You can supply a separate Runnable, but, since you're already creating a Thread, why not just make it a Runnable too, and kill two birds with one stone? On Oct 22, 3:41 pm, Kostya

Re: [android-developers] Re: Problem With Thread !

2010-10-22 Thread TreKing
2010/10/22 Kostya Vasilyev > Am I making more sense now? Indeed :-) OP, if you're trying to do some background work in a Service, look at IntentService. - TreKing

Re: [android-developers] Re: Problem With Thread !

2010-10-22 Thread Kostya Vasilyev
Right, instead of starting a thread he posts its body as a runnable to the UI thread, and sleep causes an ANR. Since he has a call to sleep, it seems that he really intends to have a thread (perhaps using sleep as a temporary placeholder for a lengthy operation, to be added later). So, the worker

Re: [android-developers] Re: Problem With Thread !

2010-10-22 Thread TreKing
2010/10/22 Kostya Vasilyev > Prakash is right - the thread needs to be started. > No, it doesn't. He's posting it to run on a handler which will call the run method. The problem is that that runs on the UI thread and the Task object is sleeping for some arbitrary time, as Dan pointed out. > Now,

Re: [android-developers] Re: Problem With Thread !

2010-10-22 Thread Kostya Vasilyev
Prakash is right - the thread needs to be started. Now, btw, why does Thead implement Runnable in Java? Seems like a recipe for confusion. -- Kostya Vasilyev -- http://kmansoft.wordpress.com 23.10.2010 0:33 пользователь "DanH" написал: > No, he's posting it as a Runnable to a Handler, it looks

[android-developers] Re: Problem With Thread !

2010-10-22 Thread DanH
> No, he's posting it as a Runnable to a Handler, it looks like. Yeah, there's a lot of that going around, and it causes a lot of confusion. Stupid to use a Thread when a Runnable will do, but that's the way it is in some examples on the net, and those examples keep getting copied. And, of cours