-3

we are developing a game using Java as a server side programming. and i have no knowledge on Java to be honest.

We are using 7-10 threads, for a table and there are 80-100 tables max, this is coming upto 1000 threads running backend.

How bad it is, will this screw up the application on a longer run ?? Thanks for your inputs

Thanks, Satish.

Satish Ravipati
  • 1,431
  • 7
  • 25
  • 40
  • 1
    you actually need some serious redesigning. Games usually don't run that many thread. – ata Jun 07 '13 at 15:35
  • This can cause starvation http://docs.oracle.com/javase/tutorial/essential/concurrency/starvelive.html – Quinma Jun 07 '13 at 15:36
  • Short answer, yes. If you are new to Java and are using that many thread you will likely run into threading issues. AND threading issues are some of the hardest problems to solve in any programming language. – John B Jun 07 '13 at 15:36
  • This has been asked before – Menelaos Jun 07 '13 at 15:39
  • 1
    1000 threads ? That isn't a game, but a malware :D – Andrea Ligios Jun 07 '13 at 15:49
  • [Similar question has already been answered](https://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-support), I have provided the link for you below I hope it would be useful for you. – grepit Jun 07 '13 at 15:35

3 Answers3

2

Check this answer. It'll explain most of the things: How many threads can a Java VM support?

Also consider redesigning your application.

Community
  • 1
  • 1
ata
  • 8,853
  • 8
  • 42
  • 68
2

My first thought is: don't do this. If you have an application that requires multiple threads then that's fine. However consider that your computer's underlying architecture (processor) can only run so many threads at a time. The Operating System (OS) simulates multi-tasking by constantly switching which thread is executing at any given time. For example, if you have a simple single core processor, only one thread can be run on it at a time, so the OS will have to swap the currently executing thread if there is more than one. Of course, this over simplifies things and ignores all the other applications running on your computer, but that's the general idea of things.

If you have lots of tasks that can be threaded, consider using a thread pool (or using a library to do it for you) where you have a set number of threads that will run tasks from a queue.

KyleM
  • 4,445
  • 9
  • 46
  • 78
0

Don't do this. Threads need to be owned by a process, not an entity like a Table. Used a ThreadPool, often ScheduledThreadPoolExecutor tends to work for most cases, and tables should request access to this resource.

djechlin
  • 59,258
  • 35
  • 162
  • 290