Abigail Decan wrote:i don't understand what close() does exactly.
i read the API and went to stackflow, but i still can't get a grasp.
for example, what does "releasing the resource" mean?
Perhaps an example might help:
If you need to read or write to a file (which is just one kind of "resource"), the operating system needs to open a 'pointer' of some kind to it. That pointer needs to:
(a) Find the file.
(b) Keep track of any updates that are made to it
while you're reading it (operating systems allow lots of users, don't forget).
(b) Track updates that
you make to it for other users.
and all of that takes time and space.
Resources therefore tend to be quite "expensive", so anything you can do to help the system release any processes, memory or cache associated with them can help performance.
close() simply says "I'm done with this resource, so you don't have to track MY use of it any more".
HIH
Winston