How to make room for other new threads?
When I run my program for a relatively long period of time, a memory problem occurs!
There are a number of threads in my program running simultaneously (for example 16) created from a single class, and in every one of them, there are two different threads, which are responsible for some different periodic jobs. So I sleep them for a random time periodically, and they do that job in a repeating manner. On the other hand, each one of theses main (16) threads, invoke some methods of the other ones, with a random delay. In order to implement this delayed invocations, without blocking the hole thread itself, I use a Timer and its method, schedule(object, delay). In another class which I pass an instant of it as the first argument of schedule(object, delay), I invoke the method of another main thread (one of those 16 threads).
But the problem is after running my program for a while, this error shows up, and the program doesn't act normally after that:
"Exception in thread "Timer-11324(or some other number like this)" java.lang.OutOfMemoryError: unable to create new native thread"
What should I do? Does these Timers and their background threads dispose after their times passed? Or, should I dispose it manually? If it is so. how can I do that?
Thanks
There is a block of code like this in some methods of a class, which each of my 16 threads initiated from this class.
class Messaging
int Broadcast_Delay;
public void Broadcast()
Timer Broadcast_Delay_Timer = new Timer();
for(int i=0 ; i < 16 ; i++)
//A random number between 0 and 100, generated by uniform distribution, as the timer delay
Broadcast_Delay = StdRandom.uniform(0, 100);
//Scheduling to run the run() method of an instance of class Broadcasting, with that random delay
Broadcast_Delay_Timer.schedule(new Broadcasting(i, trigger_pid, trigger_inum), Broadcast_Delay);
class Broadcasting
run()
}So a block of code like this runs a lot in my program, infinitely.
You are right, I put the declaration of these timers inside the methods in the main class, but they must be outside them!
You all were right!!!
But if I put the deceleration outside the methods, and directly in the main class, and if we invoke a method having this timer.schedule() continuously, is there a problem for last scheduled jobs?
Thanks
Similar Messages
-
Does anyone know how to enable editing on a new computer? I only have an 8gb phone and over 4gbs of music, half of which I don't even listen to anymore. I really want it off my phone, but when I plugged it into my new macbook nothing would delete. My old computer barely turns on so I can't even plug it into the old one to delete anything. I hit the sync button on the new computer and that didn't help either. I'd really like to upgrade to the new software but don't have the room on my phone until this music/a few apps are deleted. Any help would be appreciated!!
Here are two screen shots to show you what I am seeing. The first screen shot shows it allowing me to select (highlighted in blue) my admin user (which is what I am locced in as). The second screen shot shows it allowing me to select the "Guest" user (highlighted in blue). However when I click on the user "Orion" nothing happens. It will not change to highlight that user.
-
How to make room for new calendar entries???
Using PC Suite, I can no longer sync my Lotus Notes calendar with my Nokia phone, because the calendar on my phone is full. I also can't add any new calendar entries on my phone for the same reason.
Question: how can I delete everything older than 1 year on my Nokia phone calendar, without having to manually delete hundreds of items? That would free up the room I need, and I would set my sync settings to make sure the old calendar items don't get synced back to the phone again from Notes.
Thanks for advice on this - it is very frustrating!Which phone model do you have?
You can clear all the calendar entries on S60 based phones if you have the Calendar app in Month view; Options > Delete entry > All entries (or "Before date"). -
My new computer did one complete backup on the Time Capsule now I get the message that there is insufficient room to complete further backups.
(128 GB available, my backup size is 170GB but the time capsule is 998GB)
I suspect that information from old computers is there. How do I selectively remove that information or do I have to erase the whole Time Capsule and start over with my new computer and backup again?Check the info here.. but big warning .. it often fails.. if you want to keep your old backups archive them off the TC to USB drive.. then erase and start fresh clean backup.
http://pondini.org/TM/Time_Capsule.html -
I want to remove some photos from my account without losing them to make room for others.
I want to remove some photos from my account and save them to my computer. How do I do that?
Please see: FAQ: How Do I Download files from Revel?
-
Ok so I think I have most of the kinks worked out in how iOS 5 works for me. But I am having one problem. I have more movies than I can put on my iPad 2 (64gb) at once. So i deleted some movies from it in order to make room for some new purchases. However, now when I want to get them back on, I can't figure out how without, resyncing it with my computer. What if I only owned the iPad and didn't have the movies anywhere else? I have figure out how to get music and tv shows I have previously purchased, but can't for the life of me figure out how to get back a movie I alredy purchased.
Anyone have an anwer?Oh by the way. Goflex makes a wireless hard drive, the GoFlex Satalite, that you can use with your iPad. It's got 500 FB storage and can stream to 3 devices at once. Even android devices.
-
Time Machine no longer deletes older files to make room for new ones.
I happened to notice today, that Time Machine is failing when attempting to do updates. I also notice that the HDD is just about full. Time machine should delete the oldest backups to make room for the new ones, but for some reason this isn't happening. I also tried deleting some of the older folders manually. It says it deletes them, the folder icon disappears, but the available space never increases. If I reboot, the folders I deleted are still there. Time Machine has no problem reading the files, but apparently can't delete them. Anyone have an idea as to what might be happening? It used to work, but now something is 'broken' and I have no idea where to start looking. I am running OSX 10.5.3.
don't delete old backups from finder. delete them from TM interface. start TM and navigate to the backup you want to delete. click on the "gears" action button in finder's toolbar and select "delete backup". You'll have to enter your admin password. you might have to do this for several backups to clear up enough space. the deletion process can take a while so be patient. This is not guaranteed to make TM start deleting old backups by itself but it might.
-
I purchased tv episodes on apple tv and had to delete the episodes to make room for me to be able to download other stuff. Now I want to watch those episodes I already paid for again. How do I re-download those episodes to my apple tv without being charged again?
Welcome to the Apple community.
Assuming you are in a location that supports re-downloading of TV shows, you can download any purchased TV shows from the purchased option in the quick links section in the top right-hand corner of iTunes on your computer. -
My iphone storage is full due to my large photo library. As I want to go on taking more photos, if I back up my phone to icloud, can I then delete all my photos from my iphone to make room for new photos? Or will the next time I back up lose all those previously backed up as it is a 'new' set of data?
I just want to find the easiest and safest way of not losing all my photos while being able to take more than my iPhones storage worth as it is already full - can someone help me please? I thought icloud was the solution to not uploading my photos to the mac but I'm not sure if the way it's going is working and don't want to delete photos or lose my phone and then find out what I'm doing isn't actually storing my photos permanently. ThanksHey EmilyEliza,
As you are clearly aware, it is important for you to have backups of your important data, including all of these photos you are currently keeping on your iPhone. While it is possible to use iTunes or iCloud to do backups of your iPhone, the problem becomes how to access those backups if you have deleted the photos from your iPhone. Once you have done the backup and then removed the photos from the iPhone, the only way to access the photos is by restoring the backups to the phone. See this article for information about backups made from the iPhone -
Back up and restore your iPhone, iPad, or iPod touch using iCloud or iTunes - Apple Support
If you want to easily access the photos once they are off of the iPhone, another approach to this would be to import your photos from the iPhone into an application on your Mac, such as iPhoto. To learn how to do this, use the steps in this article -
Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support
Once those photos are on your computer, it is still important to back up those photos to somewhere else, so you can be sure of their safety before removing them from the iPhone. Your Mac’s Time Machine application is one method of doing this -
Mac Basics: Time Machine backs up your Mac - Apple Support
Thanks for using Apple Support Communities.
Happy computing,
Brett L -
My external Time Machine disk is almost full. I know TM is supposed to erase the oldest back-ups to make room for newer ones but is it safe for me to just erase the back-ups from 2 or so years ago to make room for TM as well as anything else I might want to add to this external drive?
Time Machine makes room for backups as necessary in a complex and sophisticated fashion, and it's not something to mess with lightly. However there are instructions at the bottom of this link which tell you how you can. Those instructions are part of the ultimate resource for all things Time Machine, put together by an Apple Support Communities member who is greatly missed.
-
My Nano is full and I can no longer sync more music. How do I delete duplicate songs on the Nano to make room for syncing more songs?
I had the same problem today and was able to resolve it without having to do a restore or reset. The problem had something to do with my mail accounts. The upgrade reset my mail settings, switching both my gmail and my .mac mail to "archive all mail". I went into the General Settings, disabled that setting, and resynced the phone. The "other" storage allottment dropped back down to less than a gig.
Before you restore or reset, I would try that first. -
How do you download iphone 4 apps to a dell pc to make room for apple os update
How do you download iphone 4 apps to a dell pc to make room for apple os upgrade and transfer it back to the iphone
Follow the instructions here or here.
(115390) -
HT4847 how can i delete certain item from my iCloud storage to make room for a backup?
I have been trying for weeks to figure out how to delete some items off of iCloud to make room for a backup. But I don't know how. I have deleted things off of my phone but it says thats not enough. So, how do i make the room in iCloud....
Welcome to the Apple Community.
Which items. -
How do I delete tv shows on my downloads to make room for more purchases?
How do I delete the tv shows that I purchased before now to make room for more download purchases? I want to purchse two segments of downtown Abbey that I didn't see but I get a message telling me yo delete previous tv shows or pictures.
You can tap and hold down on the the TV show icon in the Videos app and an X will pop up to delete the shows.
You may also want to connect the iPad to your computer and transfer the purchases to iTunes before you delete them so that you can store them on your computer's iTunes. Connect the iPad and launch iTunes. Right click on the iPad name on the left side under "devices" and select Transfer Purchases. You can also do this from the iTunes menu - File>Transfer Purchases.
If you live in the U.S. the UK, Canada or Australia - you can download purchased TV shows again for free in the purchased tab of iTunes as long as you use the same Apple ID that you bought the shows with. -
If i sync my phone to the computer can i then delete my old photo to make room for new ones
if i sync my phone to the computer can i then delete old photos to make room for new ones
You mean import, not sync.
iOS: Importing personal photos and videos from iOS devices to your computer
Once you are sure the photos are on your computer you can delete them from the phone.
Maybe you are looking for
-
Mac OSX Mountain Lion crashes randomly.
I've made a clean install of Mac OSX Mountain Lion in my 15" Macbook Pro late 2009 laptop. I kept reciving these intermittent lock ups and then the Macbook pro reboots (while thankfully saving whatever it needed to save before it reboots) by itself w
-
IPod shuffle recognized in windows, but not in iTunes? Anybody please help!
I need help... my BRAND NEW shuffle (4th gen) will not come up in the devices list... iTunes will not recognize anything is plugged in even though it shows on the H drive in windows....
-
WSIF Invocation (Schemac tool alternative to generate the facade class)
Hi, I am trying to create a BPEL Project which supposed to invokes an EJB using WSIF call, I have created the EJB wsif using JDeveloper for the following method signature, public void handleMessage(Message inMessage) { The Parameter Message is an Com
-
Should Not handle large base64Binary data with BPEL?
Hi, we need to implement a file saving function. I have no problem to implement the web service with Java class by using MTOM streaming but I question on the best design with BPEL for this or if BPEL should not be used for this at all. Please help. F
-
HT201401 how can i fix an error 1601 restore
how can i fix 1601 error on iphone 4