Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28472

Re: Upload using java nio

From Josip Almasi <joe@vrspace.org>
Newsgroups comp.lang.java.programmer
Subject Re: Upload using java nio
Date 2014-05-14 13:46 +0200
Organization B.net Hrvatska d.o.o.
Message-ID <lkvl26$vls$1@gregory.bnet.hr> (permalink)
References <459ec56a-b369-4261-b819-a4f232362f74@googlegroups.com>

Show all headers | View raw


On 05/13/2014 08:37 PM, William Lopes wrote:
> Hi, I'm building a network test with source code (basically) here: http://toolongdidntread.com/android/android-multipart-post-with-progress-bar/
>
> My server contains a php script that contains just a field with name = $_FILES['uploaded_file']['name']
>
> But, this java script file isn't very good, it is using the io lib, and I want change to the nio lib, because of the perfomance.

I gave up nio because it introduces a number of platform specific 
troubles. 'Troubles' being both OS and JVM impl dependent.
You may get OOM with bogus description.
IBM JVM gives more precise OOM explanation, like was it ENOMEM or 
ENOBUFS, which gives you more info on how to tune OS.

Furthermore, there's just a few nio methods that actually utilize proper 
OS functions in order to avoid unnecessary transfer between kernel mem 
and userspace mem.
IIRC, with sun jvm on linux, I've found exactly one nio method that 
actually does the job. And apache mina did not use it:> So neither did 
software using it, many many server software.
(netty does though)

I have no idea how android nio works.

But as the man said, nio is not faster than io - it all depends on other 
threads and their synchronization.
In your case, setProgress() is blocking and synchronized.
Blocking = transfer waits for bar to render.
Synchronized = slow.

Recommendiation:
Make a thread to update progress bar(s). Let it have non-blocking calls 
to update volatile/atomic internal counter(s). Use these calls instead 
of setProgress(). Make it sleep for 100-1000 ms, then render bar(s).

Regards...

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 11:37 -0700
  Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 20:37 -0400
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
      Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:00 -0400
        Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:08 -0400
          Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 19:35 -0700
            Re: Upload using java nio markspace <markspace@nospam.nospam> - 2014-05-13 20:22 -0700
              Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:35 -0700
  Re: Upload using java nio Josip Almasi <joe@vrspace.org> - 2014-05-14 13:46 +0200
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:38 -0700

csiph-web