• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:50
CEST 11:50
KST 18:50
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!15Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)84Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) Clem: "I don't have that much hope in Blizzard" Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters How would you feel about frequent/monthly balance patches for SC2? [D] Wireframe Casting Removed
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
[M] (2) Industrial Park New Map Maker - Looking for Advice - Love or Hate
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
Animated Gateway BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion HORROR STARCRAFT MOVIE How Famous was FlaSh before his Debut?
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
Path of Exile ZeroSpace Early Access is Now Live! General RTS Discussion Thread ZeroSpace at Steam NextFest - Last free demo Nintendo Switch Thread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Hello guys!
LIN1s
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8551 users

The Big Programming Thread - Page 548

Forum Index > General Forum
Post a Reply
Prev 1 546 547 548 549 550 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
Last Edited: 2014-11-17 22:27:28
November 17 2014 22:24 GMT
#10941
On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).
Time is precious. Waste it wisely.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
November 17 2014 23:38 GMT
#10942
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><
goody153
Profile Blog Joined April 2013
44282 Posts
November 18 2014 01:16 GMT
#10943
On November 18 2014 07:24 Manit0u wrote:
Show nested quote +
On November 18 2014 00:09 BByte wrote:
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).

Ok i'll try this php-mini first. Thanks .

On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


What i'm trying to convert is raw HTML + PHP coded and i would like to use majority of the codes from it since i don't want to recreate most of the functions.



Alright people has also been saying Symphony or Laravel so i'll try both and get the feel which i would like to use. And i won't be using codeigniter since people said that easier but there is no support behind it anymore.

Thank guys.
this is a quote
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
November 20 2014 02:12 GMT
#10944
Why are so many developers using MacBooks? Are they that good or is it just a trendy thing to do? I'm asking because I need a new laptop for work and am seriously considering giving it a shot even though I despise Apple products...
Time is precious. Waste it wisely.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2014-11-20 03:23:59
November 20 2014 02:28 GMT
#10945
My guess is that MacBooks are premium devices (good keyboard and touchpad, good screen, robust, good battery life etc..) and Mac OS X is POSIX compliant, which makes macbooks very usable in a Unix development setting. There are also a few productivity goodies on macbooks, like fancy multitouch touchpad gestures and such.

But they could probably do the same shit they do with a computer half as cheap. Apple's marketing and brand loyalty is just that good.
phar
Profile Joined August 2011
United States1080 Posts
November 20 2014 02:29 GMT
#10946
Solid product, and usually someone else (your company) is paying.
Who after all is today speaking about the destruction of the Armenians?
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 20 2014 02:30 GMT
#10947
On November 18 2014 08:38 Azerbaijan wrote:
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><


What container are you deploying to? How are you declaring your dependency for the javaee-web-api and what version?
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
November 20 2014 02:41 GMT
#10948
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.
Time is precious. Waste it wisely.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 20 2014 03:02 GMT
#10949
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

MSI and ASUS make good laptops for a good price, if you want something with a bit more power (especially graphics-wise).

There's a lot more options when it comes to extremely barebones machines.
Average means I'm better than half of you.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
November 20 2014 07:40 GMT
#10950
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)


RIP GOMTV. RIP PROLEAGUE.
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
November 20 2014 08:40 GMT
#10951
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




Ad. 2:

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

Source: http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space
Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
November 20 2014 14:56 GMT
#10952


Good times...
Time is precious. Waste it wisely.
raNazUra
Profile Joined December 2012
United States10 Posts
November 20 2014 21:18 GMT
#10953
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 01:07 GMT
#10954
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 02:34 GMT
#10955
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




5 minutes of googling (so if its wrong, sorry..) shows that mlockall with the jvm is used through the lucid works java agent.

Lucid Works Java Agent

Are you guys following their recommended settings?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 03:15 GMT
#10956
On November 21 2014 10:07 berated- wrote:
Show nested quote +
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 03:27 GMT
#10957
On November 21 2014 12:15 raNazUra wrote:
Show nested quote +
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.
phar
Profile Joined August 2011
United States1080 Posts
November 21 2014 05:34 GMT
#10958
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

Yea I personally wouldn't spend the markup out of my own pocket. But then again, if I had no company phone and had to get my own phone, I'd be eyeing the $100 moto e.
Who after all is today speaking about the destruction of the Armenians?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 06:03 GMT
#10959
On November 21 2014 12:27 berated- wrote:
Show nested quote +
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 10:49 GMT
#10960
On November 21 2014 15:03 raNazUra wrote:
Show nested quote +
On November 21 2014 12:27 berated- wrote:
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.


Thanks for the explanation and high level view, it makes things easier than just looking at a block of code. I'm by no means an applet expert, but, I'm going to try to restate what I believe you are trying to accomplish and the describe the approach I would take.

You want to create an applet with action buttons on it, we'll call them A, B, and C for short. When you click any of the buttons, you will add a Stop (A|B|C) button, as well as start the Action (A|B|C). Clicking the stop button will terminate the action.

If this is the case, I would have some sort of listener on buttons A, B, C like you do now. However, from looking at your code, I would change where the logic runs. For me, it makes most sense for the original button listener to
- create the thread
- create the stop button
- create the stop button listener with a reference to the created thread
- start the thread
- add the button to the screen

Since the newly created button listener has reference to the newly created thread, the only thing you'll have to do click is to stop the thread. No reason for joins anywhere. The reason I would do it like this is from a separation of concerns part. The thread should be responsible for doing whatever background logic you want to be happening is. The main applet and button listeners are responsible for the coordination of the creation of threads and buttons.
Prev 1 546 547 548 549 550 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 10m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Bisu 1406
Rain 1088
Jaedong 487
Tasteless 395
Horang2 393
BeSt 356
Soma 220
Leta 171
Hyun 153
Mini 140
[ Show more ]
Zeus 123
Mong 96
ZerO 65
Pusan 61
Killer 60
PianO 51
ToSsGirL 40
Mind 34
sorry 31
Rush 30
Aegong 26
Bale 21
ZergMaN 18
Stork 18
hero 14
Movie 14
NaDa 13
Hm[arnc] 13
JulyZerg 12
yabsab 12
GoRush 11
Noble 8
ajuk12(nOOB) 7
Yoon 6
Terrorterran 6
NotJumperer 5
Dota 2
Fuzer 154
League of Legends
JimRising 442
Counter-Strike
shoxiejesuss759
Other Games
summit1g5643
FrodaN2606
ceh91119
singsing868
Pyrionflax170
Trikslyr23
CosmosSc2 14
ZerO(Twitch)12
Organizations
Other Games
gamesdonequick1132
StarCraft: Brood War
lovetv 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH312
• mYiSmile170
• LUISG 7
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2330
Upcoming Events
The PondCast
10m
Kung Fu Cup
1h 10m
OSC
14h 10m
CrankTV Team League
1d 1h
Replay Cast
1d 14h
CrankTV Team League
2 days
Korean StarCraft League
2 days
Afreeca Starleague
2 days
RSL Revival
2 days
Serral vs SHIN
herO vs Solar
Online Event
3 days
[ Show More ]
Replay Cast
3 days
RSL Revival
3 days
Clem vs ByuN
Rogue vs Lambo
WardiTV Weekly
5 days
Sparkling Tuna Cup
6 days
PiGosaur Cup
6 days
Liquipedia Results

Completed

Proleague 2026-07-21
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.