What does the second block below run() in the anonymous class new Runnable() { that has no identifier or declaration preceding it mean:
public BackgroundThread(final Runnable runnable)
{
super(new Runnable() {
final Runnable val$runnable;
public void run()
{
Process.setThreadPriority(10);
runnable.run();
}
{
runnable = runnable1;
super();
}
});
}
Edit: yes it is decompiled code.
It's an instance initializer - called as part of the constructor. In an anonymous inner class, you can't explicitly declare a constructor, so instance initializers are sometimes used instead. In this case it's pretty pointless, as the run
method could just use runnable
directly - it would still be captured at the same time.
(This code doesn't look like it's complete or valid, actually - given that the instance initializer mentions runnable1
which doesn't appear anywhere else. I'd also not expect the instance initializer to include a super()
call. Is this possibly decompiled code?)
It's an initialization block. It gets compiled into every constructor.
See "Initializing Instance Members" in the tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With